From 518c3bc7b81db19a912b45f9fbb39dd0beea73e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20Frange=C5=BE?= Date: Mon, 23 Feb 2026 16:54:47 +0100 Subject: [PATCH] New ansible support (again) --- roles/access/templates/config-d-link.j2 | 8 ++++---- roles/access/templates/config-fs-s5800-48t4s.j2 | 4 ++-- roles/access/templates/config-fs-s5860-48xmg-u.j2 | 8 ++++---- roles/exit/tasks/dhcp.yml | 2 +- roles/exit/templates/firewall.intf.j2 | 6 +++--- roles/exit/templates/frr.conf.j2 | 10 +++++----- roles/exit/templates/isc-dhcp-relay.j2 | 4 ++-- roles/exit/templates/keepalived.conf.j2 | 6 +++--- roles/fabric/templates/interfaces.j2 | 4 ++-- roles/fabric/templates/loopback.intf.j2 | 8 ++++---- roles/fabric/templates/peerlink.intf.j2 | 4 ++-- roles/leaf/templates/frr.conf.j2 | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/roles/access/templates/config-d-link.j2 b/roles/access/templates/config-d-link.j2 index d9c8fc4..6a0bd03 100644 --- a/roles/access/templates/config-d-link.j2 +++ b/roles/access/templates/config-d-link.j2 @@ -77,7 +77,7 @@ interface {{ iface.name }} interface Vlan1 {% for address in mgmt_iface.ip_addresses %} {% if address.family.value == 4 %} - ip address {{ address.address | ipaddr('address') }} {{ address.address | ipaddr('netmask') }} + ip address {{ address.address | ansible.utils.ipaddr('address') }} {{ address.address | ansible.utils.ipaddr('netmask') }} {% else %} ipv6 address {{ address.address | upper }} {% endif %} @@ -119,14 +119,14 @@ no ip dhcp snooping {% endif %} {% for address in mgmt_iface.ip_addresses %} -{% set subnet = address.address | ipaddr('subnet') %} +{% set subnet = address.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% if prefix.custom_fields.gateway %} {% set gateway = prefix.custom_fields.gateway %} {% if gateway.family.value == 4 %} -ip route 0.0.0.0 0.0.0.0 {{ gateway.address | ipaddr('address') }} primary +ip route 0.0.0.0 0.0.0.0 {{ gateway.address | ansible.utils.ipaddr('address') }} primary {% else %} -ipv6 route default vlan1 {{ gateway.address | ipaddr('address') | upper }} primary +ipv6 route default vlan1 {{ gateway.address | ansible.utils.ipaddr('address') | upper }} primary {% endif %} {% endif %} {% endfor %} diff --git a/roles/access/templates/config-fs-s5800-48t4s.j2 b/roles/access/templates/config-fs-s5800-48t4s.j2 index d62d7fc..499e342 100644 --- a/roles/access/templates/config-fs-s5800-48t4s.j2 +++ b/roles/access/templates/config-fs-s5800-48t4s.j2 @@ -32,12 +32,12 @@ snmp-server access public security-model usm priv read public {% for iface in interfaces | sort(attribute="type.value") | sort(attribute="mgmt_only") %} {% if iface.mgmt_only %} {% for address in iface.ip_addresses %} -{% set subnet = address.address | ipaddr('subnet') %} +{% set subnet = address.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% if address.family.value == 4 %} management ip address {{ address.address }} {% if prefix.custom_fields.gateway %} -management route add gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') }} +management route add gateway {{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr('address') }} {% endif %} {% else %} management ipv6 address {{ address.address }} diff --git a/roles/access/templates/config-fs-s5860-48xmg-u.j2 b/roles/access/templates/config-fs-s5860-48xmg-u.j2 index 300e023..db9de41 100644 --- a/roles/access/templates/config-fs-s5860-48xmg-u.j2 +++ b/roles/access/templates/config-fs-s5860-48xmg-u.j2 @@ -21,17 +21,17 @@ interface {{ iface.name }} {% elif iface.mgmt_only %} {% for address in iface.ip_addresses %} -{% set subnet = address.address | ipaddr('subnet') %} +{% set subnet = address.address | ansible.utils.ipaddr('subnet') %} {% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %} {% if address.family.value == 4 %} - ip address {{ address.address | ipaddr('address') }} {{ address.address | ipaddr('netmask') }} + ip address {{ address.address | ansible.utils.ipaddr('address') }} {{ address.address | ansible.utils.ipaddr('netmask') }} {% if prefix.custom_fields.gateway %} - gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') }} + gateway {{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr('address') }} {% endif %} {% else %} ipv6 address {{ address.address | upper }} {% if prefix.custom_fields.gateway %} - ipv6 gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') | upper }} + ipv6 gateway {{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr('address') | upper }} {% endif %} {% endif %} {% endfor %} diff --git a/roles/exit/tasks/dhcp.yml b/roles/exit/tasks/dhcp.yml index 05e8454..8653e2c 100644 --- a/roles/exit/tasks/dhcp.yml +++ b/roles/exit/tasks/dhcp.yml @@ -8,7 +8,7 @@ - name: Configure DHCP relays template: - dest: '/etc/default/isc-dhcp-relay-{{ prefixes | selectattr("prefix", "==", item.0 | ipaddr("network/prefix")) | map(attribute="vrf.name") | first }}' + dest: '/etc/default/isc-dhcp-relay-{{ prefixes | selectattr("prefix", "==", item.0 | ansible.utils.ipaddr("network/prefix")) | map(attribute="vrf.name") | first }}' src: isc-dhcp-relay.j2 loop: '{{ dhcp_servers }}' loop_control: diff --git a/roles/exit/templates/firewall.intf.j2 b/roles/exit/templates/firewall.intf.j2 index 85ed21e..a9a627b 100644 --- a/roles/exit/templates/firewall.intf.j2 +++ b/roles/exit/templates/firewall.intf.j2 @@ -4,8 +4,8 @@ | map(attribute='ip_addresses') | first | selectattr('role') | selectattr('role.value', '==', 'loopback') | map(attribute='address') %} -{% set ip = lo_address | ipv4 | first %} -{% set ip6 = lo_address | ipv6 | first -%} +{% set ip = lo_address | ansible.utils.ipv4 | first %} +{% set ip6 = lo_address | ansible.utils.ipv6 | first -%} auto inside iface inside @@ -38,4 +38,4 @@ iface peerlink.2 auto peerlink.4 iface peerlink.4 vrf outside - address {{ "169.254.1.0/24" | ipaddr(exit + 1) }} + address {{ "169.254.1.0/24" | ansible.utils.ipaddr(exit + 1) }} diff --git a/roles/exit/templates/frr.conf.j2 b/roles/exit/templates/frr.conf.j2 index 1467844..c718cba 100644 --- a/roles/exit/templates/frr.conf.j2 +++ b/roles/exit/templates/frr.conf.j2 @@ -14,7 +14,7 @@ vrf outside {# Add default routes for IPv4 and IPv6. Both are over link-local addresses. #} {% set uplink = interfaces | selectattr('name', '==', iface_uplink) | first %} {% for address in uplink.ip_addresses %} -{% set gateway = address.address | ipmath(1) %} +{% set gateway = address.address | ansible.utils.ipmath(1) %} {% if address.family.value == 4 %} ip route 0.0.0.0/0 {{ gateway }} {{ iface_uplink }} {% else %} @@ -26,7 +26,7 @@ vrf outside # It is not documented anywhere and appears to be a Cumulus extension. zebra nexthop proto only -router-id {{ lo_address | ipv4 | first | ipaddr('address') }} +router-id {{ lo_address | ansible.utils.ipv4 | first | ansible.utils.ipaddr('address') }} # Default VRF. router bgp {{ asn.asn }} @@ -241,13 +241,13 @@ ipv6 prefix-list {{ prefix.vrf.name }} permit {{ prefix.prefix }} {% endfor %} {% if wg_net is defined %} -ip prefix-list vpn permit {{ wg_net | ipaddr('subnet') }} +ip prefix-list vpn permit {{ wg_net | ansible.utils.ipaddr('subnet') }} {% endif %} {% if wg_net6 is defined %} -ipv6 prefix-list vpn permit {{ wg_net6 | ipaddr('subnet') }} +ipv6 prefix-list vpn permit {{ wg_net6 | ansible.utils.ipaddr('subnet') }} {% endif %} -ip prefix-list nat permit {{ wg_ip | ipaddr('host') }} +ip prefix-list nat permit {{ wg_ip | ansible.utils.ipaddr('host') }} {% for network in nat %} ip prefix-list nat permit {{ network }} {% endfor %} diff --git a/roles/exit/templates/isc-dhcp-relay.j2 b/roles/exit/templates/isc-dhcp-relay.j2 index 0eb33fa..2bb6525 100644 --- a/roles/exit/templates/isc-dhcp-relay.j2 +++ b/roles/exit/templates/isc-dhcp-relay.j2 @@ -1,7 +1,7 @@ {% set my_server = item.0 %} {% set my_vlans = item.1 | map(attribute='vlan.vid') | sort %} -{% set my_prefix = prefixes | selectattr("prefix", "==", my_server | ipaddr("network/prefix")) | first -%} +{% set my_prefix = prefixes | selectattr("prefix", "==", my_server | ansible.utils.ipaddr("network/prefix")) | first -%} -SERVERS="{{ my_server | ipaddr('address') }}" +SERVERS="{{ my_server | ansible.utils.ipaddr('address') }}" INTF_CMD="{{ my_vlans | map('regex_replace', '^', '-id bridge.') | join(' ') }} -U bridge.{{ my_prefix.vlan.vid }}" OPTIONS="" diff --git a/roles/exit/templates/keepalived.conf.j2 b/roles/exit/templates/keepalived.conf.j2 index 7a7fb95..76bef01 100644 --- a/roles/exit/templates/keepalived.conf.j2 +++ b/roles/exit/templates/keepalived.conf.j2 @@ -1,4 +1,4 @@ -{% set dhcrelays = prefixes | selectattr('prefix', 'in', dhcp_servers | map('first') | ipaddr("network/prefix")) +{% set dhcrelays = prefixes | selectattr('prefix', 'in', dhcp_servers | map('first') | ansible.utils.ipaddr("network/prefix")) | map(attribute="vrf.name") | map('regex_replace', '^', 'dhcrelay@') %} {% set exits = [inventory_hostname, peer]|sort -%} @@ -13,11 +13,11 @@ vrrp_instance dhcrelay { interface peerlink.4 {% for exit in exits %} @{{ exit }} priority {{ loop.index }} - @{{ exit }} unicast_src_ip {{ "169.254.1.0/24" | ipaddr(loop.index + 1) | ipaddr('address') }} + @{{ exit }} unicast_src_ip {{ "169.254.1.0/24" | ansible.utils.ipaddr(loop.index + 1) | ansible.utils.ipaddr('address') }} {% endfor %} unicast_peer { {% for exit in exits %} - @^{{ exit }} {{ "169.254.1.0/24" | ipaddr(loop.index + 1) | ipaddr('address') }} + @^{{ exit }} {{ "169.254.1.0/24" | ansible.utils.ipaddr(loop.index + 1) | ansible.utils.ipaddr('address') }} {% endfor %} } notify_master "systemctl start {{ dhcrelays | join(' ') }}" diff --git a/roles/fabric/templates/interfaces.j2 b/roles/fabric/templates/interfaces.j2 index 384992b..ad4fa63 100644 --- a/roles/fabric/templates/interfaces.j2 +++ b/roles/fabric/templates/interfaces.j2 @@ -16,10 +16,10 @@ iface {{ iface.name }} ip6-forward off {% 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 %} {% if prefix.custom_fields.gateway %} - gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') }} + gateway {{ prefix.custom_fields.gateway.address | ansible.utils.ipaddr('address') }} {% endif %} {% endfor %} diff --git a/roles/fabric/templates/loopback.intf.j2 b/roles/fabric/templates/loopback.intf.j2 index 6e587e7..b2bb7b0 100644 --- a/roles/fabric/templates/loopback.intf.j2 +++ b/roles/fabric/templates/loopback.intf.j2 @@ -15,10 +15,10 @@ iface lo inet loopback address {{ address }} {% endfor %} {% if peer is defined %} -{% if loopback | ipv4 %} - vxlan-local-tunnelip {{ loopback | ipv4 | first | ipaddr('address') }} +{% if loopback | ansible.utils.ipv4 %} + vxlan-local-tunnelip {{ loopback | ansible.utils.ipv4 | first | ansible.utils.ipaddr('address') }} {% endif %} -{% if anycast | ipv4 %} - clagd-vxlan-anycast-ip {{ anycast | first | ipaddr('address') }} +{% if anycast | ansible.utils.ipv4 %} + clagd-vxlan-anycast-ip {{ anycast | first | ansible.utils.ipaddr('address') }} {% endif %} {% endif %} diff --git a/roles/fabric/templates/peerlink.intf.j2 b/roles/fabric/templates/peerlink.intf.j2 index f5a74d9..8c0fb5b 100644 --- a/roles/fabric/templates/peerlink.intf.j2 +++ b/roles/fabric/templates/peerlink.intf.j2 @@ -2,12 +2,12 @@ | selectattr('name', '==', 'lo') | map(attribute='ip_addresses') | first | selectattr('role') | selectattr('role.value', '==', 'loopback') - | map(attribute='address') | ipv4 | first | ipaddr('address') %} + | map(attribute='address') | ansible.utils.ipv4 | first | ansible.utils.ipaddr('address') %} {% set anycast_ip = interfaces | selectattr('name', '==', 'lo') | map(attribute='ip_addresses') | first | selectattr('role') | selectattr('role.value', '==', 'anycast') - | map(attribute='address') | ipv4 | first | ipaddr('address') -%} + | map(attribute='address') | ansible.utils.ipv4 | first | ansible.utils.ipaddr('address') -%} # Peer link to the other switch. auto peerlink.4094 diff --git a/roles/leaf/templates/frr.conf.j2 b/roles/leaf/templates/frr.conf.j2 index 8349ee5..9c0834c 100644 --- a/roles/leaf/templates/frr.conf.j2 +++ b/roles/leaf/templates/frr.conf.j2 @@ -19,7 +19,7 @@ service integrated-vtysh-config # It is not documented anywhere and appears to be a Cumulus extension. zebra nexthop proto only -router-id {{ lo_address | ipv4 | first | ipaddr('address') }} +router-id {{ lo_address | ansible.utils.ipv4 | first | ansible.utils.ipaddr('address') }} router bgp {{ asn.asn }} bgp bestpath as-path multipath-relax