tenks/ansible/node_networking.yml
Mark Goddard 7ad354c2af Use node state rather than 'cmd'
There are two cases when we may want to delete things:

1. if a desired node configuration or spec changes, we delete existing node
   resources.
2. if we use the teardown.yml playbook, cmd == teardown, delete
   everything, including global state.

In both cases, Tenks state (state.yml), all nodes to be deleted are given a
'state' of absent'. We should therefore use this rather than the 'cmd' variable
which only works in the latter case.

Change-Id: Icc033340c7fd882e61d90e3d086f7ba4a5b673bf
Story: 2004907
Task: 29257
2019-01-31 14:59:47 +00:00

28 lines
932 B
YAML

- hosts: localhost
tasks:
- name: Load state from file
include_vars:
file: "{{ state_file_path }}"
name: tenks_state
- hosts: hypervisors
vars:
nodes: >-
{{ hostvars.localhost.tenks_state[inventory_hostname].nodes
| default([]) }}
tasks:
- name: Configure veth pairs for each node
include_role:
name: veth-pair
vars:
veth_pair_ovs_bridge: "{{ physnet.1 | bridge_name }}"
veth_pair_ovs_link_name: "{{ physnet.0 | ovs_link_name(physnet.1) }}"
veth_pair_source_link_name: "{{ physnet.0 | source_link_name(physnet.1) }}"
veth_pair_state: "{{ physnet.0.get('state', 'present') }}"
# Loop over each physical network for each node allocated to this host.
# Allocations are stored in localhost's vars.
loop: >-
{{ nodes | subelements('physical_networks') }}
loop_control:
loop_var: physnet