99eaf48098
Instead of overwriting the physnet mappings specified in the Tenks configuration, create a separate dict that maps physnet names to their indices. Like physnet_mappings, this will be present for each hypervisor.
51 lines
1.5 KiB
YAML
51 lines
1.5 KiB
YAML
---
|
|
- name: Ensure general system requirements are installed
|
|
yum:
|
|
name: "{{ system_requirements }}"
|
|
become: true
|
|
# Don't uninstall requirements during teardown since they may already have
|
|
# been present.
|
|
when: cmd != 'teardown'
|
|
|
|
- name: Ensure log directory exists
|
|
file:
|
|
path: "{{ log_directory }}"
|
|
state: directory
|
|
become: true
|
|
# Don't remove log directory during teardown to preserve historical logs.
|
|
when: cmd != 'teardown'
|
|
|
|
- name: Check if ovs-vsctl command is present
|
|
command: ovs-vsctl --version
|
|
register: ovs_vsctl_check
|
|
failed_when: false
|
|
changed_when: false
|
|
|
|
- block:
|
|
- name: Ensure Open vSwitch package is installed
|
|
yum:
|
|
name: openvswitch
|
|
become: true
|
|
|
|
- name: Ensure Open vSwitch is started and enabled
|
|
service:
|
|
name: openvswitch
|
|
state: running
|
|
enabled: true
|
|
become: true
|
|
# Assume a non-zero return code means the command does not exist. Do this
|
|
# check to avoid installing Open vSwitch system-wide if the command already
|
|
# exists as a link to a containerised version of OVS.
|
|
when: ovs_vsctl_check.rc != 0
|
|
|
|
- name: Configure physical networks
|
|
include_tasks: physical_network.yml
|
|
vars:
|
|
network_name: "{{ pn.key }}"
|
|
tenks_bridge: "{{ bridge_prefix ~ (pn.key | physnet_name_to_index) }}"
|
|
source_interface: "{{ pn.value }}"
|
|
state: "{{ 'absent' if cmd == 'teardown' else 'present' }}"
|
|
loop: "{{ query('dict', physnet_mappings) }}"
|
|
loop_control:
|
|
loop_var: pn
|