fix: simplify ipaddr mapping in hosts file
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful

This commit is contained in:
Robert Kaussow 2024-08-21 20:54:49 +02:00
parent ead0fa501a
commit 8fe311094a
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
2 changed files with 5 additions and 3 deletions

View File

@ -6,7 +6,6 @@ network_reboot_enabled: True
network_restart_enabled: True
network_ipv6_enabled: True
network_defaultif: eth0
network_interfaces: {}
# @var network_interfaces:example: >
# network_interfaces:

View File

@ -4,8 +4,11 @@
{% if network_ipv6_enabled %}
::1 localhost6 localhost6.localdomain6
{% endif %}
{% if network_hostname is defined and network_fqdn is defined and network_defaultif is defined %}
{{ network_interfaces[network_defaultif].ipaddr | default(hostvars[inventory_hostname]["ansible_" + network_defaultif].ipv4.address) }} {{ network_fqdn }} {{ network_hostname }}
{% if network_hostname is defined and network_fqdn is defined %}
{{ network_interfaces.0.ipaddr | default(ansible_default_ipv4.address) }} {{ network_fqdn }} {{ network_hostname }}
{% if network_ipv6_enabled %}
{{ network_interfaces.0.ipv6addr | default(ansible_default_ipv6.address) }} {{ network_fqdn }} {{ network_hostname }}
{% endif %}
{% endif %}
{% if network_hosts_extra %}
{% for item in network_hosts_extra %}