veth: Remove support for EL8 / network-scripts

We no longer support EL8 or network-scripts.

Debian systems never used this role, so also removing those tasks.

Change-Id: I17b93c75a1ff8eb8d636247696f4a1709ca486d5
This commit is contained in:
Mark Goddard 2023-11-01 17:15:28 +00:00
parent bd9043dca0
commit 8dc73ed2fe
5 changed files with 45 additions and 137 deletions

View File

@ -1,42 +0,0 @@
---
# FIXME: Not persistent!
- name: Ensure veth pair exists (Debian)
command:
cmd: "ip link add dev {{ item.device }} type veth peer name {{ item.peer_device }}"
creates: "/sys/class/net/{{ item.device }}"
become: true
with_items: "{{ veth_interfaces }}"
- name: Set veth MTU (Debian)
command: "ip link set {{ item.device }} mtu {{ item.mtu }}"
become: true
with_items: "{{ veth_interfaces }}"
when: item.mtu is defined and item.mtu
- name: Set veth peer MTU (Debian)
command: "ip link set {{ item.peer_device }} mtu {{ item.peer_mtu }}"
become: true
with_items: "{{ veth_interfaces }}"
when: item.peer_mtu is defined and item.peer_mtu
- name: Plug veth into bridge (Debian)
command: "ip link set {{ item.device }} master {{ item.bridge }}"
become: true
with_items: "{{ veth_interfaces }}"
when: item.bridge is defined
- name: Plug veth peer into bridge (Debian)
command: "ip link set {{ item.peer_device }} master {{ item.peer_bridge }}"
become: true
with_items: "{{ veth_interfaces }}"
when: item.peer_bridge is defined
- name: Ensure veth is up (Debian)
command: "ip link set {{ item.device }} up"
with_items: "{{ veth_interfaces }}"
become: true
- name: Ensure veth peer is up (Debian)
command: "ip link set {{ item.peer_device }} up"
with_items: "{{ veth_interfaces }}"
become: true

View File

@ -1,6 +0,0 @@
---
- include_tasks: network-scripts.yml
when: ansible_facts.distribution_major_version | int < 9
- include_tasks: network-manager.yml
when: ansible_facts.distribution_major_version | int >= 9

View File

@ -1,2 +1,46 @@
---
- include_tasks: "{{ ansible_facts.os_family }}.yml"
- name: Ensure veth network manager connections file exists
template:
src: veth-nmconnection.j2
dest: "/etc/NetworkManager/system-connections/{{ item.device }}.nmconnection"
owner: root
group: root
mode: 0600
with_items: "{{ veth_interfaces }}"
become: True
register: veth_result
- name: Ensure veth peer network manager connections file exists
template:
src: peer-nmconnection.j2
dest: "/etc/NetworkManager/system-connections/{{ item.peer_device }}.nmconnection"
owner: root
group: root
mode: 0600
with_items: "{{ veth_interfaces }}"
become: True
register: peer_result
# NOTE(bbezak) For some reason adding veth pair via loading files to nmcli needs
# peer device to be loaded first. If not, can't start interface.
# "Error: Connection activation failed: p-br0-ovs failed to create resources:
# Failed to create veth interface 'p-br0-ovs' for 'p-br0-ovs': exists"
- name: Add veth interfaces to network manager
shell: |
nmcli connection load /etc/NetworkManager/system-connections/{{ item[0].item.peer_device }}.nmconnection &&
nmcli connection load /etc/NetworkManager/system-connections/{{ item[0].item.device }}.nmconnection
with_together:
- "{{ veth_result.results }}"
- "{{ peer_result.results }}"
when: item[0] is changed or item[1] is changed
become: True
- name: Start veth interfaces with network manager
shell: |
nmcli connection up {{ item[0].item.device }} &&
nmcli connection up {{ item[0].item.peer_device }}
with_together:
- "{{ veth_result.results }}"
- "{{ peer_result.results }}"
when: item[0] is changed or item[1] is changed
become: True

View File

@ -1,45 +0,0 @@
- name: Ensure veth network manager connections file exists
template:
src: veth-nmconnection.j2
dest: "/etc/NetworkManager/system-connections/{{ item.device }}.nmconnection"
owner: root
group: root
mode: 0600
with_items: "{{ veth_interfaces }}"
become: True
register: veth_result
- name: Ensure veth peer network manager connections file exists
template:
src: peer-nmconnection.j2
dest: "/etc/NetworkManager/system-connections/{{ item.peer_device }}.nmconnection"
owner: root
group: root
mode: 0600
with_items: "{{ veth_interfaces }}"
become: True
register: peer_result
# NOTE(bbezak) For some reason adding veth pair via loading files to nmcli needs
# peer device to be loaded first. If not, can't start interface.
# "Error: Connection activation failed: p-br0-ovs failed to create resources:
# Failed to create veth interface 'p-br0-ovs' for 'p-br0-ovs': exists"
- name: Add veth interfaces to network manager
shell: |
nmcli connection load /etc/NetworkManager/system-connections/{{ item[0].item.peer_device }}.nmconnection &&
nmcli connection load /etc/NetworkManager/system-connections/{{ item[0].item.device }}.nmconnection
with_together:
- "{{ veth_result.results }}"
- "{{ peer_result.results }}"
when: item[0] is changed or item[1] is changed
become: True
- name: Start veth interfaces with network manager
shell: |
nmcli connection up {{ item[0].item.device }} &&
nmcli connection up {{ item[0].item.peer_device }}
with_together:
- "{{ veth_result.results }}"
- "{{ peer_result.results }}"
when: item[0] is changed or item[1] is changed
become: True

View File

@ -1,43 +0,0 @@
---
- name: Ensure veth sysconfig network control scripts exist
copy:
src: "{{ item }}"
dest: "{{ network_scripts_dir }}/{{ item }}"
owner: root
group: root
mode: 0755
with_items:
- "ifup-veth"
- "ifdown-veth"
become: True
register: ctl_result
- name: Ensure veth sysconfig network interface files exist
template:
src: ifcfg-veth.j2
dest: "{{ network_scripts_dir }}/ifcfg-{{ item.device }}"
owner: root
group: root
mode: 0644
with_items: "{{ veth_interfaces }}"
become: True
register: veth_result
- name: Ensure veth peer sysconfig network interface files exist
template:
src: ifcfg-peer.j2
dest: "{{ network_scripts_dir }}/ifcfg-{{ item.peer_device }}"
owner: root
group: root
mode: 0644
with_items: "{{ veth_interfaces }}"
become: True
register: peer_result
- name: Bounce veth interfaces
shell: ifdown {{ item[0].item.device }} ; ifup {{ item[0].item.device }}
with_together:
- "{{ veth_result.results }}"
- "{{ peer_result.results }}"
when: ctl_result is changed or item[0] is changed or item[1] is changed
become: True