108 lines
3.4 KiB
YAML
108 lines
3.4 KiB
YAML
# If virtualport_type is defined for any networks, include OVS dependencies
|
|
- when: networks|selectattr('virtualport_type', 'defined')|map(attribute='name')|list|length > 0
|
|
block:
|
|
|
|
# Install OVS dependencies
|
|
- name: Install OVS dependencies
|
|
include_role:
|
|
name: 'parts/ovs'
|
|
|
|
# Create any OVS Bridges that have been defined
|
|
- name: Create OVS Bridges
|
|
openvswitch_bridge:
|
|
bridge: "{{ item.bridge }}"
|
|
state: present
|
|
when: item.virtualport_type is defined and item.virtualport_type == "openvswitch"
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
# Create the global, root-managed libvirt networks to which we will
|
|
# attach the undercoud and overcloud virtual machines.
|
|
- name: Create libvirt networks
|
|
virt_net:
|
|
command: define
|
|
state: present
|
|
name: "{{ item.name }}"
|
|
xml: '{{ lookup("template", "network.xml.j2") }}'
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
- name: Start libvirt networks
|
|
virt_net:
|
|
command: start
|
|
name: "{{ item.name }}"
|
|
state: active
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
- name: Mark libvirt networks as autostarted
|
|
virt_net:
|
|
name: "{{ item.name }}"
|
|
autostart: "yes"
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
register: net_autostart
|
|
ignore_errors: true
|
|
|
|
# https://bugs.launchpad.net/tripleo-quickstart/+bug/1581676
|
|
# There is a bug w/ virt_net and RHEL where the network xml
|
|
# file is not written to /etc/libvirt/qemu/networks/ This causes
|
|
# network to be considered transient.
|
|
- when: net_autostart.changed != true
|
|
block:
|
|
|
|
- name: Check if "virsh net-autostart" was successful
|
|
debug: msg="Some libvirt networks were not set to autostart. Please see
|
|
https://bugs.launchpad.net/tripleo-quickstart/+bug/1581676"
|
|
|
|
# get the network xml from the running network
|
|
- name: Get libvirt networks xml
|
|
virt_net:
|
|
command: get_xml
|
|
name: "{{ item.name }}"
|
|
with_items: "{{ networks }}"
|
|
register: net_xml
|
|
become: true
|
|
|
|
# copy the xml to a file
|
|
- name: copy network-xml to file
|
|
copy: content={{ item.get_xml }} dest=/tmp/network-{{item.item.name}}.xml
|
|
with_items: "{{ net_xml.results }}"
|
|
become: true
|
|
|
|
# redefine the network w/ virsh, this will write the xml file to
|
|
# /etc/libvirt/qemu/networks/ and it will no longer be transient
|
|
- name: redefine the libvirt networks so the config is written to /etc/libvirt
|
|
command: virsh net-define /tmp/network-{{item.name}}.xml
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
# Now we're ready to mark the network autostart
|
|
- name: Mark libvirt networks as autostarted
|
|
virt_net:
|
|
name: "{{ item.name }}"
|
|
autostart: "yes"
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
# Whitelist the bridges associated with these networks for
|
|
# access using qemu [helper networking][helper]. Later on we
|
|
# create virtual machines use an unprivileged `qemu://session`
|
|
# connection, and we connect to the networks using the bridge names.
|
|
#
|
|
# [helper]: http://wiki.qemu.org/Features-Done/HelperNetworking
|
|
- name: Whitelist bridges for unprivileged access
|
|
lineinfile:
|
|
dest: "{{ qemu_bridge_conf }}"
|
|
line: "allow {{item.bridge}}"
|
|
with_items: "{{ networks }}"
|
|
become: true
|
|
|
|
# We're going to want to store things in `working_dir` so ensure it
|
|
# exists first. `working_dir` is a directory on the target host.
|
|
- name: Ensure remote working dir exists
|
|
file:
|
|
path: "{{ working_dir }}"
|
|
state: directory
|
|
become: true
|