2022-12-18 23:43:40 +01:00
|
|
|
---
|
2023-08-13 21:41:47 +02:00
|
|
|
- block:
|
|
|
|
- name: "{{ services_service_name }} : veth : create interface directory hierarchy"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ system_etc_root_directory }}/network/interfaces/{{ item }}"
|
|
|
|
state: "directory"
|
|
|
|
mode: 0755
|
|
|
|
loop:
|
|
|
|
- "{{ services_service_iface_name }}"
|
|
|
|
- "{{ services_service_iface_name }}/ifup.d"
|
|
|
|
- "{{ services_service_iface_name }}/ifdown.d"
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : interface up scripts"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./veth/ifupdown.d/{{ item }}"
|
|
|
|
dest: "\
|
|
|
|
{{ system_etc_root_directory }}/network/interfaces/\
|
|
|
|
{{ services_service_iface_name }}/ifup.d/{{ item }}"
|
|
|
|
mode: 0755
|
|
|
|
loop:
|
|
|
|
- "00-interface"
|
|
|
|
- "01-veth0"
|
|
|
|
register: services_setup_user_veth_interface_up
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : configure interface"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./veth/interface"
|
|
|
|
dest: "/etc/network/interfaces.d/{{ services_service_iface_name }}"
|
|
|
|
mode: 0644
|
|
|
|
register: services_setup_user_veth_interface_file
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : restart interface"
|
|
|
|
ansible.builtin.shell: |
|
|
|
|
if ip link show dev {{ services_service_iface_name }}
|
|
|
|
then
|
|
|
|
ifdown {{ services_service_iface_name }} && ifup {{ services_service_iface_name }}
|
|
|
|
fi
|
|
|
|
when:
|
|
|
|
services_setup_user_veth_interface_up.changed or
|
|
|
|
services_setup_user_veth_interface_file.changed
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : interface down scripts"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./veth/ifupdown.d/{{ item }}"
|
|
|
|
dest: "\
|
|
|
|
{{ system_etc_root_directory }}/network/interfaces/\
|
|
|
|
{{ services_service_iface_name }}/ifdown.d/{{ item }}"
|
|
|
|
mode: 0755
|
|
|
|
loop:
|
|
|
|
- "00-interface"
|
|
|
|
- "01-veth0"
|
|
|
|
register: services_setup_user_veth_interface_up
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : interface bridge up scripts"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "./veth/bridge-ifupdown.d/90-veth"
|
|
|
|
dest: "\
|
|
|
|
{{ system_etc_root_directory }}/network/interfaces/\
|
|
|
|
{{ services_service_bridge_name }}/{{ item }}/90-{{ services_service_iface_name }}"
|
|
|
|
mode: 0755
|
|
|
|
loop:
|
|
|
|
- "ifup.d"
|
|
|
|
- "ifdown.d"
|
|
|
|
|
|
|
|
- name: "{{ services_service_name }} : veth : add ifupdown commands to sudoers"
|
|
|
|
community.general.sudoers:
|
|
|
|
name: "{{ services_service_iface_name }}"
|
|
|
|
state: "present"
|
|
|
|
user: "{{ services_service_user_name }}"
|
|
|
|
commands:
|
|
|
|
- "/usr/sbin/ifup {{ services_service_iface_name }}"
|
|
|
|
- "/usr/sbin/ifdown --ignore-errors {{ services_service_iface_name }}"
|
|
|
|
nopassword: true
|
|
|
|
|
2022-12-11 00:41:50 +01:00
|
|
|
vars:
|
|
|
|
services_service_iface_name: "veth-{{ services_service_name }}"
|
2023-08-13 21:41:47 +02:00
|
|
|
services_service_bridge_name: "br0"
|
2023-07-29 14:38:57 +02:00
|
|
|
services_service_iface_inet_address: "\
|
|
|
|
{{ services_host_services[services_service_name].inet_address }}"
|
2023-08-13 21:41:47 +02:00
|
|
|
services_service_iface_inet_prefixlen: 24
|
2023-07-29 14:38:57 +02:00
|
|
|
services_service_iface_inet6_address: "\
|
|
|
|
{{ services_host_services[services_service_name].inet6_address }}"
|
2023-08-13 21:41:47 +02:00
|
|
|
services_service_iface_inet6_prefixlen: 64
|