1 # If virtualport_type is defined for any networks, include OVS dependencies
2 - when: networks|selectattr('virtualport_type', 'defined')|map(attribute='name')|list|length > 0
5 # Install OVS dependencies
6 - name: Install OVS dependencies
10 # Create any OVS Bridges that have been defined
11 - name: Create OVS Bridges
13 bridge: "{{ item.bridge }}"
15 when: item.virtualport_type is defined and item.virtualport_type == "openvswitch"
16 with_items: "{{ networks }}"
19 # TODO(apuimedo) drop this back to vm tasks once we have proper DNS
20 - name: get a list of MACs to use
22 nodes: "{{ vm_nodes }}"
23 networks: "{{ networks }}"
24 register: node_mac_map
28 # Create the global, root-managed libvirt networks to which we will
29 # attach the undercoud and vm virtual machines.
30 - name: Create libvirt networks
34 name: "{{ item.name }}"
35 xml: '{{ lookup("template", "network.xml.j2") }}'
36 with_items: "{{ networks }}"
39 - name: Start libvirt networks
42 name: "{{ item.name }}"
44 with_items: "{{ networks }}"
47 - name: Mark libvirt networks as autostarted
49 name: "{{ item.name }}"
51 with_items: "{{ networks }}"
53 register: net_autostart
56 # https://bugs.launchpad.net/tripleo-quickstart/+bug/1581676
57 # There is a bug w/ virt_net and RHEL where the network xml
58 # file is not written to /etc/libvirt/qemu/networks/ This causes
59 # network to be considered transient.
60 - when: not net_autostart.changed
63 - name: Check if "virsh net-autostart" was successful
64 debug: msg="Some libvirt networks were not set to autostart. Please see
65 https://bugs.launchpad.net/tripleo-quickstart/+bug/1581676"
67 # get the network xml from the running network
68 - name: Get libvirt networks xml
71 name: "{{ item.name }}"
72 with_items: "{{ networks }}"
76 # copy the xml to a file
77 - name: copy network-xml to file
78 copy: content={{ item.get_xml }} dest=/tmp/network-{{ item.item.name }}.xml
79 with_items: "{{ net_xml.results }}"
82 # redefine the network w/ virsh, this will write the xml file to
83 # /etc/libvirt/qemu/networks/ and it will no longer be transient
84 - name: redefine the libvirt networks so the config is written to /etc/libvirt
85 command: virsh net-define /tmp/network-{{ item.name }}.xml
86 with_items: "{{ networks }}"
89 # Now we're ready to mark the network autostart
90 - name: Mark libvirt networks as autostarted
92 name: "{{ item.name }}"
94 with_items: "{{ networks }}"
97 # Whitelist the bridges associated with these networks for
98 # access using qemu [helper networking][helper]. Later on we
99 # create virtual machines use an unprivileged `qemu://session`
100 # connection, and we connect to the networks using the bridge names.
102 # [helper]: http://wiki.qemu.org/Features-Done/HelperNetworking
103 - name: Whitelist bridges for unprivileged access on CentOS
105 dest: '/etc/qemu-kvm/bridge.conf' # Needs to be /etc/qemu/bridge.conf if supporting Fedora
106 line: "allow {{ item.bridge }}"
107 with_items: "{{ networks }}"
109 - ansible_os_family == "RedHat"
112 - name: Whitelist bridges for unprivileged access on Ubuntu or Fedora
114 dest: '/etc/qemu/bridge.conf'
115 line: "allow {{ item.bridge }}"
117 with_items: "{{ networks }}"
119 - ansible_facts['distribution'] == "Ubuntu"
122 # We're going to want to store things in `working_dir` so ensure it
123 # exists first. `working_dir` is a directory on the target host.
124 - name: Ensure remote working dir exists
126 path: "{{ working_dir }}"