[interfaces] Configure interfaces only if an IP exists

certbot_on_virtu
_benjamin 2020-08-19 17:36:25 +02:00
parent a47058fcac
commit fa41bdb816
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@
{% set vlan_name = (item.name | replace('_', '-')) %}
{% set subnet = query('ldap', 'network', vlan_name) %}
{% set ips = query('ldap', 'ip', ansible_hostname, vlan_name) %}
{% if (ips | ipv4 | length) > 0 %}
auto {{ interfaces[item.name] }}
iface {{ interfaces[item.name] }} inet static
{% for ip in (ips | ipv4) %}
@ -28,7 +29,9 @@ iface {{ interfaces[item.name] }} inet static
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% if (ips | ipv6 | length) > 0 %}
iface {{ interfaces[item.name] }} inet6 static
{% for ip in (ips | ipv6) %}
address {{ ip }}/64
@ -40,3 +43,4 @@ iface {{ interfaces[item.name] }} inet6 static
{% endfor %}
{% endif %}
{% endif %}
{% endif %}