Remove 'controllers' group in favour of localhost

Only a single controller would have ever been required, so explicitly
referencing localhost makes more sense.

Also, remove a duplicate 'when' attribute.
This commit is contained in:
Will Miller 2018-08-23 15:15:09 +00:00
parent 5a04d38baa
commit a4c21a2d92
6 changed files with 9 additions and 18 deletions

View File

@ -3,7 +3,7 @@
tasks:
- include_tasks: host_setup.yml
- hosts: controllers
- hosts: localhost
tasks:
- include_tasks: schedule.yml
@ -19,11 +19,10 @@
vm_name: "{{ item.0.name }}"
physnet: "{{ item.1 }}"
# Loop over each physical network for each VM allocated to this host.
# Allocations are stored in the controller node's vars.
# Allocations are stored in localhost's vars.
loop: >-
{{ hostvars[groups.controllers.0].allocations.result[
inventory_hostname] | default([])
| subelements('physical_networks') }}
{{ hostvars['localhost'].allocations.result[inventory_hostname]
| default([]) | subelements('physical_networks') }}
- hosts: libvirt
tasks:
@ -42,7 +41,7 @@
- include_tasks: libvirt_create_vms.yml
vars:
# Allocations are stored in the controller node's vars.
# Allocations are stored in the localhost's vars.
vms: >-
{{ hostvars[groups.controllers.0].allocations.result[
inventory_hostname] | default([]) }}
{{ hostvars['localhost'].allocations.result[inventory_hostname]
| default([]) }}

View File

@ -1,6 +1,3 @@
[controllers]
# Empty group to provide delaration of controllers group.
[hypervisors:children]
libvirt

View File

@ -1,5 +1,2 @@
[controllers]
localhost ansible_connection=local
[libvirt]
localhost ansible_connection=local

View File

@ -10,7 +10,7 @@
# Start off by assuming the source interface is direct, unless proven
# otherwise.
- set_fact:
source_type: 'direct'
source_type: direct
- name: Get source interface details
command: ip -details link show {{ source_interface }}
@ -79,8 +79,6 @@
options:peer={{ veth_prefix + tenks_bridge +
veth_bridge_ovs_suffix }}
when: if_details.stdout_lines[-1].split()[0] == 'openvswitch'
- name: Plug source interface into Tenks bridge
when: source_type == 'direct'
openvswitch_port:

View File

@ -12,7 +12,7 @@
set_fact:
hypervisor_vars: >-
{{ hypervisor_vars | default({}) | combine({item: hostvars[item]}) }}
loop: "{{ groups['controllers'] }}"
loop: "{{ groups['hypervisors'] }}"
- name: Schedule VMs to hypervisors
tenks_schedule: