Remove dependency on bridge-utils
bridge-utils is considered legacy and many distributions do not ship it as default. Change-Id: Id2f9d779d12a5135d7d7e7a4783c6f3a0c8647ca Story: 2004302 Task: 27861
This commit is contained in:
parent
583d3232ae
commit
602fdfa26b
@ -15,9 +15,7 @@ This role manages a veth pair. Actions:
|
||||
Requirements
|
||||
------------
|
||||
|
||||
The host should have the `ip` and `ovs-vsctl` commands accessible. If
|
||||
`veth_pair_plug_into_source` is enabled, the command `brctl` must also be
|
||||
accessible.
|
||||
The host should have the `ip` and `ovs-vsctl` commands accessible.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
@ -1,16 +1,17 @@
|
||||
---
|
||||
- name: Unplug veth from source bridge
|
||||
command: >-
|
||||
brctl delif {{ veth_pair_source_bridge }}
|
||||
{{ veth_pair_source_link_name }}
|
||||
register: res
|
||||
failed_when:
|
||||
- res.rc != 0
|
||||
# Case where veth is already unplugged.
|
||||
- not (res.rc == 1 and 'does not exist' in res.stderr)
|
||||
changed_when: res.rc == 0
|
||||
- block:
|
||||
- include_tasks: is-attached.yml
|
||||
vars:
|
||||
bridge: "{{ veth_pair_source_bridge }}"
|
||||
interface: "{{ veth_pair_source_link_name }}"
|
||||
|
||||
- name: Unplug veth from source bridge
|
||||
command: >-
|
||||
ip link set {{ veth_pair_source_link_name }} nomaster
|
||||
when:
|
||||
- veth_pair_is_attached
|
||||
become: true
|
||||
when: veth_pair_plug_into_source | bool
|
||||
become: true
|
||||
|
||||
- name: Delete veth pair
|
||||
command: >-
|
||||
|
22
ansible/roles/veth-pair/tasks/is-attached.yml
Normal file
22
ansible/roles/veth-pair/tasks/is-attached.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
# This will determine if interface is attached to bridge and set a fact called
|
||||
# veth_pair_is_attached containing the result
|
||||
|
||||
- name: Set a default value for veth_pair_is_attached
|
||||
set_fact:
|
||||
veth_pair_is_attached: false
|
||||
|
||||
- name: Speculatively check {{ interface }}'s master
|
||||
command: >-
|
||||
realpath /sys/class/net/{{ interface }}/master
|
||||
register: master_result
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Determine if {{ interface }} is attached to {{ bridge }}
|
||||
vars:
|
||||
master: "{{ master_result.stdout | basename }}"
|
||||
set_fact:
|
||||
veth_pair_is_attached: "{{ master == bridge }}"
|
||||
when: master_result.rc == 0
|
@ -23,14 +23,17 @@
|
||||
port: "{{ veth_pair_ovs_link_name }}"
|
||||
become: true
|
||||
|
||||
- name: Plug veth into source bridge
|
||||
command: >-
|
||||
brctl addif {{ veth_pair_source_bridge }}
|
||||
{{ veth_pair_source_link_name }}
|
||||
register: res
|
||||
failed_when:
|
||||
- res.rc != 0
|
||||
- "'already a member of a bridge' not in res.stderr"
|
||||
changed_when: "'already a member of a bridge' not in res.stderr"
|
||||
- block:
|
||||
- include_tasks: is-attached.yml
|
||||
vars:
|
||||
bridge: "{{ veth_pair_source_bridge }}"
|
||||
interface: "{{ veth_pair_source_link_name }}"
|
||||
|
||||
- name: Plug veth into source bridge
|
||||
command: >-
|
||||
ip link set {{ veth_pair_source_link_name }} master
|
||||
{{ veth_pair_source_bridge }}
|
||||
when:
|
||||
- not veth_pair_is_attached
|
||||
become: true
|
||||
when: veth_pair_plug_into_source | bool
|
||||
become: true
|
||||
|
Loading…
Reference in New Issue
Block a user