mirror of
				https://gitea.0xace.cc/ansible-galaxy/network.git
				synced 2025-10-30 18:47:23 +00:00 
			
		
		
		
	routes check hack update
This commit is contained in:
		| @@ -16,15 +16,22 @@ | |||||||
|     notify: |     notify: | ||||||
|       - Reload interface with nmcli |       - Reload interface with nmcli | ||||||
|  |  | ||||||
|   - name: Get existing routes |   - 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: Set fact about existing and new routes |   - 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 | ||||||
|     set_fact: |     set_fact: | ||||||
|       existing_routes4: "{{ existing_routes4_res.stdout | hash('sha256') }}" |       existing_routes4: "{{ existing_routes4_res.stdout | hash('sha256') }}" | ||||||
|       new_routes4: "{{ '' if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}" |       new_routes4: "{{ '' if iface.routes4 is not defined else (iface.routes4|join(', ') | hash('sha256')) }}" | ||||||
|  |       existing_routes6: "{{ existing_routes6_res.stdout | hash('sha256') }}" | ||||||
|  |       new_routes6: "{{ '' if iface.routes6 is not defined else (iface.routes6|join(', ') | hash('sha256')) }}" | ||||||
|  |  | ||||||
|   #- debug: |   #- debug: | ||||||
|   #    msg: "{{ existing_routes4_res.stdout | hash('sha256') }}" |   #    msg: "{{ existing_routes4_res.stdout | hash('sha256') }}" | ||||||
| @@ -32,7 +39,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: Add routes and rules with nmcli |   - 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') }}" | ||||||
| @@ -44,7 +51,7 @@ | |||||||
|       vlanid: "{{ iface.vlanid | default(omit) }}" |       vlanid: "{{ iface.vlanid | default(omit) }}" | ||||||
|       routes4: "{{ omit if existing_routes4 != new_routes4 else iface.routes4 }}" |       routes4: "{{ omit if existing_routes4 != new_routes4 else iface.routes4 }}" | ||||||
|       routing_rules4: "{{ iface.routing_rules4 | default(omit) }}" |       routing_rules4: "{{ iface.routing_rules4 | default(omit) }}" | ||||||
|       routes6: "{{ iface.routes6 | default(omit) }}" |       routes6: "{{ omit if existing_routes6 != new_routes6 else iface.routes6 }}" | ||||||
|       routing_rules6: "{{ iface.routing_rules6 | default(omit) }}" |       routing_rules6: "{{ iface.routing_rules6 | default(omit) }}" | ||||||
|       mtu: "{{ iface.mtu | default(0) }}" |       mtu: "{{ iface.mtu | default(0) }}" | ||||||
|       zone: "{{ iface.zone | default(omit) }}" |       zone: "{{ iface.zone | default(omit) }}" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user