fix nmcli

This commit is contained in:
ace 2021-10-26 18:51:16 +03:00
parent 246441558a
commit feab9fb4a3
No known key found for this signature in database
GPG Key ID: 2E47CC17BA7F8CF0
2 changed files with 25 additions and 18 deletions

View File

@ -2,3 +2,6 @@
# use 'network-scripts' for network-scripts and lo iface for BGP IPs # use 'network-scripts' for network-scripts and lo iface for BGP IPs
network: "nm" network: "nm"
network_nm_iface: "dummy0" network_nm_iface: "dummy0"
# null for auto
network_nm_iface_mtu: null

View File

@ -18,23 +18,28 @@
- Restart loopback - Restart loopback
when: network == 'network-scripts' when: network == 'network-scripts'
- name: Add dummy interface and add IPs
community.general.nmcli: - block:
type: dummy - name: BGP IPs string for nmcli
conn_name: "{{ network_nm_iface }}" set_fact:
ip4: | ips: |-
[ {%- set ips_list = [] %}
{% set ips = [] %} {%- for protocol_static in bird.bgp.static %}
{% for protocol_static in bird.bgp.static %} {%- for network in protocol_static['networks'][ansible_fqdn] %}
{% for network in protocol_static['networks'][ansible_fqdn] %} {{ ips_list.append(network['ip'] + '/' + network['mask_dash']) }}
{{ ips.append(network['ip'] + '/' + network['mask_dash']) }} {%- endfor %}
{% endfor %} {%- endfor %}
{% endfor %} {{ ips_list | join(', ') }}
"{{ ips | join(',') }}"
] - name: Add dummy interface and add IPs
state: present community.general.nmcli:
notify: type: dummy
- Reload dummy interface conn_name: "{{ network_nm_iface }}"
ip4: "{{ ips }}"
mtu: "{{ network_nm_iface_mtu }}"
state: present
notify:
- Reload dummy interface
when: network == 'nm' when: network == 'nm'
- name: Add BIRD config - name: Add BIRD config
@ -50,4 +55,3 @@
state: started state: started
enabled: yes enabled: yes
daemon_reload: yes daemon_reload: yes