diff --git a/roles/alpine/templates/interfaces.j2 b/roles/alpine/templates/interfaces.j2 index 882e93e..7aef1a4 100644 --- a/roles/alpine/templates/interfaces.j2 +++ b/roles/alpine/templates/interfaces.j2 @@ -33,14 +33,14 @@ iface {{ iface.name }} {% for address in iface.ip_addresses %} address {{ address.address }} {% if address.family.value == 4 %} -{% set subnet = address.address | ipaddr('subnet') %} +{% set subnet = address.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% set gateway = prefix.custom_fields.gateway.address %} {% if gateway is defined and gateway != address.address %} {% if iface.vrf %} - up ip route add default via {{ gateway | ipaddr('address') }} {% if iface.vrf.name %}vrf {{ iface.vrf.name }}{% endif +%} + up ip route add default via {{ gateway | ansible.utils.ipaddr('address') }} {% if iface.vrf.name %}vrf {{ iface.vrf.name }}{% endif +%} {% else %} - gateway {{ gateway | ipaddr('address') }} + gateway {{ gateway | ansible.utils.ipaddr('address') }} {% endif %} {% endif %} {% endif %} diff --git a/roles/collector/templates/snmp.conf.j2 b/roles/collector/templates/snmp.conf.j2 index ec9aedb..98b43b8 100644 --- a/roles/collector/templates/snmp.conf.j2 +++ b/roles/collector/templates/snmp.conf.j2 @@ -6,7 +6,7 @@ agents = [ {% for address in query("netbox.netbox.nb_lookup", "devices", api_filter=snmp_hosts, raw_data=true) | selectattr("primary_ip4") | map(attribute="primary_ip4.address") - | ipaddr("int") | sort | ipaddr("address") %} + | ansible.utils.ipaddr("int") | sort | ansible.utils.ipaddr("address") %} "{{ address }}", {% endfor %} ] diff --git a/roles/dnsmasq/templates/10-ranges.conf.j2 b/roles/dnsmasq/templates/10-ranges.conf.j2 index 2d64db4..bc55b0e 100644 --- a/roles/dnsmasq/templates/10-ranges.conf.j2 +++ b/roles/dnsmasq/templates/10-ranges.conf.j2 @@ -1,11 +1,11 @@ {% for prefix in prefixes | selectattr('custom_fields.dhcp_server') | sort(attribute='vlan.name') %} -{% if prefix.custom_fields.dhcp_server.address | ipaddr('address') == primary_ip4 %} +{% if prefix.custom_fields.dhcp_server.address | ansible.utils.ipaddr('address') == primary_ip4 %} # {{ prefix.vlan.name }} {% for range in prefix.custom_fields.dhcp_ranges | default([], true) %} -dhcp-range = set:{{ prefix.vlan.name }},{{ range.start_address | ipaddr('address') }},{{ range.end_address | ipaddr('address') }},{{ prefix.prefix | ipaddr('netmask') }} +dhcp-range = set:{{ prefix.vlan.name }},{{ range.start_address | ansible.utils.ipaddr('address') }},{{ range.end_address | ansible.utils.ipaddr('address') }},{{ prefix.prefix | ansible.utils.ipaddr('netmask') }} {% endfor %} {% if prefix.custom_fields.gateway %} -dhcp-option = tag:{{ prefix.vlan.name }},option:router,{{ prefix.custom_fields.gateway.address | ipaddr('address') }} +dhcp-option = tag:{{ prefix.vlan.name }},option:router,{{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr('address') }} {% endif -%} {% for host in hostvars.values() | selectattr('interfaces', 'defined') %} @@ -24,5 +24,5 @@ dhcp-host = {{ interface.mac_address | lower }},{{ address }},{{ interface.devic # custom reservations {% for reservation in reservations | default([]) %} -dhcp-host = {{ reservation.mac | lower }},{{ reservation.ip | ipaddr('address') }},{{ reservation.host | lower }} +dhcp-host = {{ reservation.mac | lower }},{{ reservation.ip | ansible.utils.ipaddr('address') }},{{ reservation.host | lower }} {% endfor %} diff --git a/roles/proxmox-backup/templates/hosts.j2 b/roles/proxmox-backup/templates/hosts.j2 index a4ac92f..0869ec3 100644 --- a/roles/proxmox-backup/templates/hosts.j2 +++ b/roles/proxmox-backup/templates/hosts.j2 @@ -8,5 +8,5 @@ ff02::2 ip6-allrouters ff02::3 ip6-allhosts {% for address in interfaces | selectattr('name', '==', 'lo') | map(attribute='ip_addresses') | first %} -{{ address.address | ipaddr('address') }} {{ address.dns_name }} {{ inventory_hostname }} +{{ address.address | ansible.utils.ipaddr('address') }} {{ address.dns_name }} {{ inventory_hostname }} {% endfor %} diff --git a/roles/proxmox/templates/loopback.intf.j2 b/roles/proxmox/templates/loopback.intf.j2 index 81c428c..26fc0c4 100644 --- a/roles/proxmox/templates/loopback.intf.j2 +++ b/roles/proxmox/templates/loopback.intf.j2 @@ -1,7 +1,7 @@ {% set lo = hostvars[inventory_hostname].interfaces | selectattr('name', '==', 'lo') | first %} {% set vxlan_ip = lo.ip_addresses | selectattr('family.value', '==', 4) | map(attribute='address') | first - | ipaddr('address') %} + | ansible.utils.ipaddr('address') %} iface lo # without this the local tunnel IP is sometimes advertised as 0.0.0.0 on boot vxlan-local-tunnelip {{ vxlan_ip }} diff --git a/roles/radvd/templates/radvd.conf.j2 b/roles/radvd/templates/radvd.conf.j2 index 2fd4723..bab538d 100644 --- a/roles/radvd/templates/radvd.conf.j2 +++ b/roles/radvd/templates/radvd.conf.j2 @@ -3,7 +3,7 @@ | selectattr('enabled') %} {% for address in iface.ip_addresses | selectattr("family.value", "==", 6) %} {# get the gateway for this subnet #} -{% set subnet = address.address | ipaddr('subnet') %} +{% set subnet = address.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% set gateway = prefix.custom_fields.gateway.address %} {# if we are gateway, send RAs on this interface #} diff --git a/roles/windows/tasks/interface_address.yml b/roles/windows/tasks/interface_address.yml index cce3528..5e31b1a 100644 --- a/roles/windows/tasks/interface_address.yml +++ b/roles/windows/tasks/interface_address.yml @@ -2,7 +2,7 @@ win_shell: > New-NetIPAddress -InterfaceAlias {{ interface.name }} -AddressFamily IPv{{ address.family.value }} - -IPAddress "{{ address.address | ipaddr("address") }}" -PrefixLength {{ address.address | ipaddr("prefix") }} + -IPAddress "{{ address.address | ansible.utils.ipaddr("address") }}" -PrefixLength {{ address.address | ansible.utils.ipaddr("prefix") }} register: result changed_when: "not result.stderr or 'Instance MSFT_NetIPAddress already exists' not in result.stderr" failed_when: false @@ -17,7 +17,7 @@ New-NetRoute -InterfaceAlias {{ interface.name }} -AddressFamily IPv{{ address.family.value }} -DestinationPrefix {{ "0.0.0.0/0" if address.family.value == 4 else "::/0" }} - -NextHop {{ prefix.custom_fields.gateway.address | ipaddr("address") }} + -NextHop {{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr("address") }} register: result changed_when: "not result.stderr or 'Instance MSFT_NetRoute already exists' not in result.stderr" failed_when: false diff --git a/templates/ansible.intf.j2 b/templates/ansible.intf.j2 index cd0bb29..465e03d 100644 --- a/templates/ansible.intf.j2 +++ b/templates/ansible.intf.j2 @@ -19,11 +19,11 @@ iface {{ iface.name }}{% if iface.name == 'lo' %} inet loopback{% endif +%} {% endif %} {% for ip in iface.ip_addresses %} address {{ ip.address }} -{% set subnet = ip.address | ipaddr('subnet') %} +{% set subnet = ip.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% set gateway = prefix.custom_fields.gateway.address %} {% if gateway is defined %} - gateway {{ gateway | ipaddr('address') }} + gateway {{ gateway | ansible.utils.ipaddr('address') }} {% endif %} {% endfor %} diff --git a/templates/hosts.j2 b/templates/hosts.j2 index 8864201..5bf6d9d 100644 --- a/templates/hosts.j2 +++ b/templates/hosts.j2 @@ -11,5 +11,5 @@ ff02::3 ip6-allhosts | map(attribute='interfaces') | flatten | map(attribute='ip_addresses') | flatten | selectattr('dns_name') %} -{{ address.address | ipaddr('address') }} {{ address.dns_name }} {{ address.dns_name | split('.') | first }} +{{ address.address | ansible.utils.ipaddr('address') }} {{ address.dns_name }} {{ address.dns_name | split('.') | first }} {% endfor %}