
Although my shell returns 127 when a command is not found, Ansible's command module seems to be getting 2. Assume non-zero means not installed.
46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
---
|
|
- name: Ensure general system requirements are installed
|
|
yum:
|
|
name: "{{ system_requirements }}"
|
|
become: true
|
|
|
|
- name: Ensure log directory exists
|
|
file:
|
|
path: "{{ log_directory }}"
|
|
state: directory
|
|
become: true
|
|
|
|
- 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: "{{ item.0 }}"
|
|
tenks_bridge: "{{ bridge_prefix ~ idx }}"
|
|
source_interface: "{{ item.1 }}"
|
|
# Sort to ensure we always enumerate in the same order.
|
|
loop: "{{ physnet_mappings | dictsort }}"
|
|
loop_control:
|
|
index_var: idx
|