This commit is contained in:
ace
2021-10-27 17:19:40 +03:00
parent 6b9e036057
commit ccb0e81fbe
5 changed files with 54 additions and 41 deletions

View File

@ -1,6 +1,6 @@
---
- block:
- name: Configure interface with nmcli
- name: "{{ iface.conn_name }} | Configure interface with nmcli"
community.general.nmcli:
conn_name: "{{ iface.conn_name }}"
type: "{{ iface.type | default('ethernet') }}"
@ -17,22 +17,22 @@
- Reload interface with nmcli
register: configure_interface
- name: Add interface to reload list
- name: "{{ iface.conn_name }} | Add interface to reload list"
set_fact:
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
when: configure_interface.changed
- name: Get existing ipv4 routes
- name: "{{ iface.conn_name }} | Get existing ipv4 routes"
shell: nmcli -g ipv4.routes connection show {{ iface.conn_name }}
register: existing_routes4_res
changed_when: False
- name: Get existing ipv6 routes
- name: "{{ iface.conn_name }} | Get existing ipv6 routes"
shell: nmcli -g ipv6.routes connection show {{ iface.conn_name }}
register: existing_routes6_res
changed_when: False
- name: Set fact about existing and new ipv4/ipv6 routes
- name: "{{ iface.conn_name }} | Set fact about existing and new ipv4/ipv6 routes"
set_fact:
existing_routes4: "{{ existing_routes4_res.stdout | hash('sha256') }}"
new_routes4: "{{ (echo.stdout | hash('sha256')) if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}"
@ -45,7 +45,7 @@
#- debug:
# msg: "{{ '' if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}"
- name: Update routes and rules with nmcli
- name: "{{ iface.conn_name }} | Update routes and rules with nmcli"
community.general.nmcli:
conn_name: "{{ iface.conn_name }}"
type: "{{ iface.type | default('ethernet') }}"
@ -66,10 +66,10 @@
- Reload interface with nmcli
register: update_routes_and_rules
- name: Add interface to reload list
- name: "{{ iface.conn_name }} | Add interface to reload list"
set_fact:
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
when: update_routes_and_rules.changed
- debug:
msg: "{{ reload_interfaces }}"
#- debug:
# msg: "{{ reload_interfaces }}"