mirror of
https://gitea.0xace.cc/ansible-galaxy/network.git
synced 2024-11-24 22:36:38 +00:00
update
This commit is contained in:
parent
6b9e036057
commit
ccb0e81fbe
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Up interface
|
- name: Reload interface with ifdown ; ifup
|
||||||
shell: |
|
shell: |
|
||||||
ifdown {{ item }} ; ifup {{ item }}
|
ifdown {{ item }} ; ifup {{ item }}
|
||||||
loop: "{{ reload_interfaces | unique }}"
|
loop: "{{ reload_interfaces | unique }}"
|
||||||
|
@ -5,20 +5,17 @@
|
|||||||
name: network-scripts
|
name: network-scripts
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- include_tasks: network_scripts.yaml
|
- 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
|
when: network.network_scripts is defined
|
||||||
|
|
||||||
- name: Set blank routes symbol
|
|
||||||
command: echo -n
|
|
||||||
register: echo
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Create array for interfaces to reload
|
|
||||||
set_fact:
|
|
||||||
reload_interfaces: []
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Configure interfaces and routes with nmcli
|
- name: Configure interfaces and routes with nmcli
|
||||||
include: network_manager.yaml iface={{ item }}
|
include: network_manager.yaml iface={{ item }}
|
||||||
when: network.network_manager is defined
|
when: network.network_manager is defined
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: Configure interface with nmcli
|
- name: "{{ iface.conn_name }} | Configure interface with nmcli"
|
||||||
community.general.nmcli:
|
community.general.nmcli:
|
||||||
conn_name: "{{ iface.conn_name }}"
|
conn_name: "{{ iface.conn_name }}"
|
||||||
type: "{{ iface.type | default('ethernet') }}"
|
type: "{{ iface.type | default('ethernet') }}"
|
||||||
@ -17,22 +17,22 @@
|
|||||||
- Reload interface with nmcli
|
- Reload interface with nmcli
|
||||||
register: configure_interface
|
register: configure_interface
|
||||||
|
|
||||||
- name: Add interface to reload list
|
- name: "{{ iface.conn_name }} | Add interface to reload list"
|
||||||
set_fact:
|
set_fact:
|
||||||
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
|
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
|
||||||
when: configure_interface.changed
|
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 }}
|
shell: nmcli -g ipv4.routes connection show {{ iface.conn_name }}
|
||||||
register: existing_routes4_res
|
register: existing_routes4_res
|
||||||
changed_when: False
|
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 }}
|
shell: nmcli -g ipv6.routes connection show {{ iface.conn_name }}
|
||||||
register: existing_routes6_res
|
register: existing_routes6_res
|
||||||
changed_when: False
|
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:
|
set_fact:
|
||||||
existing_routes4: "{{ existing_routes4_res.stdout | hash('sha256') }}"
|
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')) }}"
|
new_routes4: "{{ (echo.stdout | hash('sha256')) if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}"
|
||||||
@ -45,7 +45,7 @@
|
|||||||
#- debug:
|
#- debug:
|
||||||
# msg: "{{ '' if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}"
|
# 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:
|
community.general.nmcli:
|
||||||
conn_name: "{{ iface.conn_name }}"
|
conn_name: "{{ iface.conn_name }}"
|
||||||
type: "{{ iface.type | default('ethernet') }}"
|
type: "{{ iface.type | default('ethernet') }}"
|
||||||
@ -66,10 +66,10 @@
|
|||||||
- Reload interface with nmcli
|
- Reload interface with nmcli
|
||||||
register: update_routes_and_rules
|
register: update_routes_and_rules
|
||||||
|
|
||||||
- name: Add interface to reload list
|
- name: "{{ iface.conn_name }} | Add interface to reload list"
|
||||||
set_fact:
|
set_fact:
|
||||||
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
|
reload_interfaces: "{{ reload_interfaces + [ iface.conn_name ] }}"
|
||||||
when: update_routes_and_rules.changed
|
when: update_routes_and_rules.changed
|
||||||
|
|
||||||
- debug:
|
#- debug:
|
||||||
msg: "{{ reload_interfaces }}"
|
# msg: "{{ reload_interfaces }}"
|
||||||
|
@ -1,34 +1,40 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: Create interfaces config files
|
- name: "{{ iface.name }} | Configure interface"
|
||||||
template:
|
template:
|
||||||
src: "ifcfg-{{ item.type | default('ethernet') }}.j2"
|
src: "ifcfg-{{ iface.type | default('ethernet') }}.j2"
|
||||||
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}"
|
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ iface.name }}"
|
||||||
notify:
|
notify:
|
||||||
- Up interface
|
- Reload interface with ifdown ; ifup
|
||||||
loop: "{{ network.network_scripts.iface }}"
|
register: configure_interface
|
||||||
|
|
||||||
- name: Create routing table in rt_tables
|
- name: "{{ iface.name }} | Add interface to reload list"
|
||||||
template:
|
set_fact:
|
||||||
src: rt_tables.j2
|
reload_interfaces: "{{ reload_interfaces + [ iface.name ] }}"
|
||||||
dest: /etc/iproute2/rt_tables
|
when: configure_interface.changed
|
||||||
notify:
|
|
||||||
- Up interface
|
|
||||||
|
|
||||||
- name: Create routing rules for interfaces
|
- name: "{{ iface.name }} | Create routing rules for interface"
|
||||||
template:
|
template:
|
||||||
src: rule.j2
|
src: rule.j2
|
||||||
dest: "/etc/sysconfig/network-scripts/rule-{{ item.name }}"
|
dest: "/etc/sysconfig/network-scripts/rule-{{ iface.name }}"
|
||||||
notify:
|
notify:
|
||||||
- Up interface
|
- Reload interface with ifdown ; ifup
|
||||||
loop: "{{ network.network_scripts.iface }}"
|
register: create_routing_rules
|
||||||
|
|
||||||
- name: Create routes for interfaces
|
- name: "{{ iface.name }} | Add interface to reload list"
|
||||||
|
set_fact:
|
||||||
|
reload_interfaces: "{{ reload_interfaces + [ iface.name ] }}"
|
||||||
|
when: create_routing_rules.changed
|
||||||
|
|
||||||
|
- name: "{{ iface.name }} | Create routes for interface"
|
||||||
template:
|
template:
|
||||||
src: route.j2
|
src: route.j2
|
||||||
dest: "/etc/sysconfig/network-scripts/route-{{ item.name }}"
|
dest: "/etc/sysconfig/network-scripts/route-{{ iface.name }}"
|
||||||
notify:
|
notify:
|
||||||
- Up interface
|
- Reload interface with ifdown ; ifup
|
||||||
loop: "{{ network.network_scripts.iface }}"
|
register: create_routes
|
||||||
|
|
||||||
when: network.network_scripts is defined
|
- name: "{{ iface.name }} | Add interface to reload list"
|
||||||
|
set_fact:
|
||||||
|
reload_interfaces: "{{ reload_interfaces + [ iface.name ] }}"
|
||||||
|
when: create_routes.changed
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
- name: Set blank routes symbol
|
||||||
|
command: echo -n
|
||||||
|
register: echo
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Create array for interfaces to reload
|
||||||
|
set_fact:
|
||||||
|
reload_interfaces: []
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Include interfaces configuration tasks
|
- name: Include interfaces configuration tasks
|
||||||
include: "{{ ansible_os_family }}/{{ ansible_distribution_version }}.yaml"
|
include: "{{ ansible_os_family }}/{{ ansible_distribution_version }}.yaml"
|
||||||
|
Loading…
Reference in New Issue
Block a user