fix network-scripts and nmcli variants for loopback interface

This commit is contained in:
ace 2021-10-26 18:12:38 +03:00
parent 359d858e60
commit fd0c9bd34f
No known key found for this signature in database
GPG Key ID: 2E47CC17BA7F8CF0
3 changed files with 36 additions and 30 deletions

4
defaults/main.yaml Normal file
View File

@ -0,0 +1,4 @@
# use 'nm' for network-manager and dummy0 iface for BGP IPs
# use 'network-scripts' for network-scripts and lo iface for BGP IPs
network: "nm"
network_nm_iface: "dummy0"

View File

@ -16,4 +16,4 @@
ifdown lo ; ifup lo ifdown lo ; ifup lo
- name: Reload dummy interface - name: Reload dummy interface
command: nmcli conn up {{ dummy_iface | default('dummy0') }} command: nmcli conn up {{ network_nm_iface }}

View File

@ -1,39 +1,41 @@
--- ---
- name: Install network scripts
package:
name: network-scripts
state: present
- name: Install BIRD - name: Install BIRD
package: package:
name: bird name: bird
state: present state: present
- name: Update ifcfg-lo config - block:
template: - name: Install network scripts
src: ifcfg-lo.j2 package:
dest: /etc/sysconfig/network-scripts/ifcfg-lo name: network-scripts
notify: state: present
- Restart loopback
#- name: Add dummy interface and add IPs - name: Update ifcfg-lo config
# community.general.nmcli: template:
# type: dummy src: ifcfg-lo.j2
# conn_name: "{{ dummy_iface | default('dummy0') }}" dest: /etc/sysconfig/network-scripts/ifcfg-lo
# ip4: '{{ item.ip4 }}' notify:
# state: present - Restart loopback
# notify: when: network == 'network-scripts'
# - Reload dummy interface
# loop: | - name: Add dummy interface and add IPs
# [ community.general.nmcli:
# {% for protocol_static in bird.bgp.static %} type: dummy
# {% for network in protocol_static['networks'][ansible_fqdn] %} conn_name: "{{ network_nm_iface }}"
# { ip4: |
# "ip4": "{{ network['ip'] + '/' + network['mask_dash'] }}" [
# }, {% set ips = [] %}
# {% endfor %} {% for protocol_static in bird.bgp.static %}
# {% endfor %} {% for network in protocol_static['networks'][ansible_fqdn] %}
# ] {{ ips.append(network['ip'] + '/' + network['mask_dash']) }}
{% endfor %}
{% endfor %}
"{{ ips | join(',') }}"
]
state: present
notify:
- Reload dummy interface
when: network == 'nm'
- name: Add BIRD config - name: Add BIRD config
template: template: