This commit is contained in:
ace
2023-09-24 03:48:12 +03:00
parent 8ba560a810
commit 8aa06f4399
8 changed files with 136 additions and 39 deletions

View File

@ -1,22 +0,0 @@
---
- block:
- name: Install network scripts
package:
name: network-scripts
state: present
- name: Create routing table in rt_tables
template:
src: rt_tables.j2
dest: /etc/iproute2/rt_tables
- name: Configure interfaces and routes with network-scripts
include: network_scripts.yaml iface={{ item }}
loop: "{{ network.network_scripts.iface }}"
when: network.network_scripts is defined
- name: Configure interfaces and routes with nmcli
include: network_manager.yaml iface={{ item }}
when: network.network_manager is defined
loop: "{{ network.network_manager.iface }}"

View File

@ -1,27 +1,37 @@
---
- block:
- name: Configure network with network-scripts
when: network.network_scripts is defined
block:
- name: Install network scripts
package:
name: network-scripts
state: present
- name: Create routing table in rt_tables
template:
src: rt_tables.j2
dest: /etc/iproute2/rt_tables
- name: Configure interfaces and routes with network-scripts
include: network_scripts.yaml iface={{ item }}
vars:
iface: "{{ item }}"
include_tasks: network_scripts.yaml
loop: "{{ network.network_scripts.iface }}"
when: network.network_scripts is defined
- block:
- name: Configure network with Network Manager
when: network.network_manager is defined
block:
- name: Install NetworkManager-dispatcher-routing-rules
package:
name:
- NetworkManager-dispatcher-routing-rules
state: present
when: ansible_distribution_major_version == '7'
- name: Configure interfaces and routes with nmcli
include: network_manager.yaml iface={{ item }}
vars:
iface: "{{ item }}"
include_tasks: network_manager.yaml
loop: "{{ network.network_manager.iface }}"
when: network.network_manager is defined

View File

@ -25,12 +25,12 @@
when: configure_interface.changed
- name: "{{ iface.conn_name }} | Get existing ipv4 routes"
shell: nmcli -g ipv4.routes connection show {{ iface.conn_name }}
shell: nmcli -g ipv4.routes connection show "{{ iface.conn_name }}"
register: existing_routes4_res
changed_when: False
- name: "{{ iface.conn_name }} | Get existing ipv6 routes"
shell: nmcli -g ipv6.routes connection show {{ iface.conn_name }}
shell: nmcli -g ipv6.routes connection show "{{ iface.conn_name }}"
register: existing_routes6_res
changed_when: False