Skip to content

Commit a721b8b

Browse files
authored
Fix filter not found issue for ansible >= 2.14 (#20771) (#21295)
What is the motivation for this PR? Ansible 2.14+ enforces FQCN (with a few exceptions for “very core” filters like default, to_json, dictsort that are still built into Jinja2/Ansible). Directly using filters like ipaddr, ipv6 will fail with filter not found issue. How did you do it? This change fixed the issue by adding ansible.utils. to the ipaddr and ipv6 filters used in the templates. How did you verify/test it? Tested using ansible 2.13 and ansible 2.19.
1 parent a14968e commit a721b8b

33 files changed

+67
-67
lines changed

ansible/roles/eos/templates/dpu-tor.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

ansible/roles/eos/templates/m0-mx.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ interface {{ bp_ifname }}
9494
no shutdown
9595
!
9696
router bgp {{ host['bgp']['asn'] }}
97-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
97+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
9898
!
9999
graceful-restart restart-time {{ bgp_gr_timer }}
100100
graceful-restart
@@ -104,7 +104,7 @@ router bgp {{ host['bgp']['asn'] }}
104104
neighbor {{ remote_ip }} remote-as {{ asn }}
105105
neighbor {{ remote_ip }} description {{ asn }}
106106
neighbor {{ remote_ip }} next-hop-self
107-
{% if remote_ip | ipv6 %}
107+
{% if remote_ip | ansible.utils.ipv6 %}
108108
address-family ipv6
109109
neighbor {{ remote_ip }} activate
110110
exit

ansible/roles/eos/templates/t0-8-lag-leaf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

ansible/roles/eos/templates/t0-backend-leaf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ interface {{ bp_ifname }}
128128
no shutdown
129129
!
130130
router bgp {{ host['bgp']['asn'] }}
131-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
131+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
132132
!
133133
graceful-restart restart-time {{ bgp_gr_timer }}
134134
graceful-restart
@@ -138,7 +138,7 @@ router bgp {{ host['bgp']['asn'] }}
138138
neighbor {{ remote_ip }} remote-as {{ asn }}
139139
neighbor {{ remote_ip }} description {{ asn }}
140140
neighbor {{ remote_ip }} next-hop-self
141-
{% if remote_ip | ipv6 %}
141+
{% if remote_ip | ansible.utils.ipv6 %}
142142
address-family ipv6
143143
neighbor {{ remote_ip }} activate
144144
exit

ansible/roles/eos/templates/t0-isolated-d2u254s1-tor.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ interface {{ bp_ifname }}
9494
no shutdown
9595
!
9696
router bgp {{ host['bgp']['asn'] }}
97-
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
97+
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
9898
!
9999
graceful-restart restart-time {{ bgp_gr_timer }}
100100
graceful-restart
101101
!
102102
{% for asn, remote_ips in host['bgp']['peers'].items() %}
103103
{% for remote_ip in remote_ips %}
104-
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
neighbor {{ remote_ip }} remote-as {{ asn }}
106106
neighbor {{ remote_ip }} description {{ asn }}
107107
neighbor {{ remote_ip }} next-hop-self
108-
{% if remote_ip | ipv6 %}
108+
{% if remote_ip | ansible.utils.ipv6 %}
109109
address-family ipv6
110110
neighbor {{ remote_ip }} activate
111111
exit

ansible/roles/eos/templates/t0-leaf-lag-2.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

ansible/roles/eos/templates/t0-leaf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['bgp']['router-id'] if host['bgp']['router-id'] is defined else host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
@@ -112,7 +112,7 @@ router bgp {{ host['bgp']['asn'] }}
112112
neighbor {{ remote_ip }} route-reflector-client
113113
neighbor {{ remote_ip }} additional-paths send any
114114
{% endif %}
115-
{% if remote_ip | ipv6 %}
115+
{% if remote_ip | ansible.utils.ipv6 %}
116116
address-family ipv6
117117
neighbor {{ remote_ip }} activate
118118
exit

ansible/roles/eos/templates/t0-mclag-leaf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

ansible/roles/eos/templates/t0-v6-leaf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['bgp']['router-id'] | ipaddr('address') }}
104+
router-id {{ host['bgp']['router-id'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

ansible/roles/eos/templates/t1-28-lag-spine.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ interface {{ bp_ifname }}
101101
no shutdown
102102
!
103103
router bgp {{ host['bgp']['asn'] }}
104-
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ipaddr('address') }}
104+
router-id {{ host['interfaces']['Loopback0']['ipv4'] | ansible.utils.ipaddr('address') }}
105105
!
106106
{% for asn, remote_ips in host['bgp']['peers'].items() %}
107107
{% for remote_ip in remote_ips %}
108108
neighbor {{ remote_ip }} remote-as {{ asn }}
109109
neighbor {{ remote_ip }} description {{ asn }}
110110
neighbor {{ remote_ip }} next-hop-self
111-
{% if remote_ip | ipv6 %}
111+
{% if remote_ip | ansible.utils.ipv6 %}
112112
address-family ipv6
113113
neighbor {{ remote_ip }} activate
114114
exit

0 commit comments

Comments
 (0)