network_interfaces is working for my router

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-06-04 17:14:30 +02:00
parent f1ac6f269b
commit f57b1f1b3e
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@ glob_network_interfaces:
id: 1 id: 1
gateway: "185.230.76.62" gateway: "185.230.76.62"
dns: "{{ query('ldap', 'ip', 'routeur-templier', 'srv') | ipv4 | first }}" dns: "{{ query('ldap', 'ip', 'routeur-templier', 'srv') | ipv4 | first }}"
gateway_v6: "2a0c:700:3002::ff:fe02:102" gateway_v6: "2a0c:700:3012::ff:fe02:112"
- name: adm - name: adm
id: 42 id: 42
dns: "{{ query('ldap', 'ip', 'routeur-templier', 'adm') | ipv4 | first }}" dns: "{{ query('ldap', 'ip', 'routeur-templier', 'adm') | ipv4 | first }}"

View File

@ -0,0 +1,5 @@
---
interfaces:
adm: ens18
srv: ens19
srv_nat: ens20

View File

@ -1,6 +1,6 @@
#!/usr/bin/env ansible-playbook #!/usr/bin/env ansible-playbook
--- ---
- hosts: vm,!routeur - hosts: vm
vars: vars:
network_interfaces: "{{ glob_network_interfaces | default({}) | combine(loc_network_interfaces | default({})) }}" network_interfaces: "{{ glob_network_interfaces | default({}) | combine(loc_network_interfaces | default({})) }}"
roles: roles:

View File

@ -12,7 +12,7 @@ iface {{ interfaces[item.name] }} inet static
{% endfor %} {% endfor %}
network {{ subnet_network }} network {{ subnet_network }}
netmask {{ subnet_netmask }} netmask {{ subnet_netmask }}
{% if item.gateway is defined %} {% if item.gateway is defined and item.gateway not in (ips | ipv4) %}
gateway {{ item.gateway }} gateway {{ item.gateway }}
{% endif %} {% endif %}
{% if item.metric is defined %} {% if item.metric is defined %}
@ -41,7 +41,7 @@ iface {{ interfaces[item.name] }} inet6 static
{% for ip in (ips | ipv6) %} {% for ip in (ips | ipv6) %}
address {{ ip }}/64 address {{ ip }}/64
{% endfor %} {% endfor %}
{% if item.gateway_v6 is defined %} {% if item.gateway_v6 is defined and item.gateway_v6 not in (ips | ipv6) %}
gateway {{ item.gateway_v6 }} gateway {{ item.gateway_v6 }}
{% endif %} {% endif %}
accept_ra 0 accept_ra 0