From 956351629f7a47093575a7a6459362fc7bd07514 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Mon, 10 Sep 2018 14:45:37 +0000 Subject: [PATCH] Fix veth-pair role for teardown * Don't delete the OVS bridge specified, as it will already be deleted when the role is called. * Clarify the behaviour of the role for each value of `cmd` in the README. * Succintify main.yml. --- ansible/roles/veth-pair/README.md | 16 ++++++++++------ ansible/roles/veth-pair/tasks/absent.yml | 7 ------- ansible/roles/veth-pair/tasks/main.yml | 8 +------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/ansible/roles/veth-pair/README.md b/ansible/roles/veth-pair/README.md index 6c1cc26..918fc12 100644 --- a/ansible/roles/veth-pair/README.md +++ b/ansible/roles/veth-pair/README.md @@ -1,12 +1,16 @@ Veth Pair ========= -This role creates a veth pair. It will plug one end into the specified OVS -bridge and, optionally, can plug the other end into a source Linux bridge. If -`veth_pair_state` is `absent`, it will ensure the veth pair is not plugged into -the OVS bridge; if `veth_pair_plug_into_source` is enabled, it will ensure the -veth pair is not plugged into the source bridge; finally, it will ensure the -veth pair itself does not exist. +This role manages a veth pair. Actions: + + * If `veth_pair_state` is `present`, it will create the veth pair and + plug one end into the specified OVS bridge. If `veth_pair_plug_into_source` + is enabled, it will also plug the other end into/from a source Linux + bridge. + + * If `veth_pair_state` is `absent`, it will ensure the veth pair does not exist; if + `veth_pair_plug_into_source` is also enabled, it will ensure the veth pair is + not plugged into the source bridge. Requirements ------------ diff --git a/ansible/roles/veth-pair/tasks/absent.yml b/ansible/roles/veth-pair/tasks/absent.yml index 6e4e19e..dfa4d83 100644 --- a/ansible/roles/veth-pair/tasks/absent.yml +++ b/ansible/roles/veth-pair/tasks/absent.yml @@ -1,11 +1,4 @@ --- -- name: Unplug veth from OVS bridge - openvswitch_port: - bridge: "{{ veth_pair_ovs_bridge }}" - port: "{{ veth_pair_ovs_link_name }}" - state: absent - become: true - - name: Unplug veth from source bridge command: >- brctl delif {{ veth_pair_source_bridge }} diff --git a/ansible/roles/veth-pair/tasks/main.yml b/ansible/roles/veth-pair/tasks/main.yml index ab9de44..6bb7471 100644 --- a/ansible/roles/veth-pair/tasks/main.yml +++ b/ansible/roles/veth-pair/tasks/main.yml @@ -1,8 +1,2 @@ --- -- name: Ensure veth pair is absent - include_tasks: absent.yml - when: veth_pair_state == 'absent' - -- name: Ensure veth pair is present - include_tasks: present.yml - when: veth_pair_state != 'absent' +- include_tasks: "{{ veth_pair_state }}.yml"