diff --git a/roles/firewall/templates/ip6tables.j2 b/roles/firewall/templates/ip6tables.j2 index 602bf0f..8346682 100644 --- a/roles/firewall/templates/ip6tables.j2 +++ b/roles/firewall/templates/ip6tables.j2 @@ -66,7 +66,7 @@ -A INPUT -i lo -m comment --comment "lo accept all inet6" -j ACCEPT {% if firewall_ssh_whitelist | length %} -{% for ip in firewall_ssh_whitelist | ipv6 %} +{% for ip in firewall_ssh_whitelist | ansible.utils.ipv6 %} -A INPUT -p tcp -m tcp --dport 22 --source {{ ip }} -m comment --comment "accept {{ ip }} ssh 22/tcp6" -j ACCEPT {% endfor %} {% endif %} diff --git a/roles/firewall/templates/ipset.j2 b/roles/firewall/templates/ipset.j2 index 5164736..f41343d 100644 --- a/roles/firewall/templates/ipset.j2 +++ b/roles/firewall/templates/ipset.j2 @@ -9,8 +9,8 @@ add {{ name }} {{ ip_or_net }} {% endmacro %} {% macro render_dual_stack_ipset(ipset, name, type="hash:net", family="inet", timeout=None) %} -{{ render_ipset(ipset | ipv4, name + "4", type=type, family=family, timeout=timeout) }} -{{ render_ipset(ipset | ipv6, name + "6", type=type, family="inet6", timeout=timeout) }} +{{ render_ipset(ipset | ansible.utils.ipv4, name + "4", type=type, family=family, timeout=timeout) }} +{{ render_ipset(ipset | ansible.utils.ipv6, name + "6", type=type, family="inet6", timeout=timeout) }} {% endmacro %} {{ render_dual_stack_ipset([], 'block') }} diff --git a/roles/firewall/templates/ipset.v4.j2 b/roles/firewall/templates/ipset.v4.j2 index 0e7dd77..bc25531 100644 --- a/roles/firewall/templates/ipset.v4.j2 +++ b/roles/firewall/templates/ipset.v4.j2 @@ -2,7 +2,7 @@ create {{ name }} {{ type | default('hash:net') }} family {{ family }} counters {% if timeout %}timeout {{ timeout }}{% endif %} -exist flush {{ name }} {% if ipset | length %} -{% for ip_or_net in ipset | ipv4 %} +{% for ip_or_net in ipset | ansible.utils.ipv4 %} add {{ name }} {{ ip_or_net }} {% endfor %} {% endif %} diff --git a/roles/firewall/templates/ipset.v6.j2 b/roles/firewall/templates/ipset.v6.j2 index 90596d2..83fb607 100644 --- a/roles/firewall/templates/ipset.v6.j2 +++ b/roles/firewall/templates/ipset.v6.j2 @@ -2,7 +2,7 @@ create {{ name }} {{ type | default('hash:net') }} family {{ family }} counters {% if timeout %}timeout {{ timeout }}{% endif %} -exist flush {{ name }} {% if ipset | length %} -{% for ip_or_net in ipset | ipv6 %} +{% for ip_or_net in ipset | ansible.utils.ipv6 %} add {{ name }} {{ ip_or_net }} {% endfor %} {% endif %} diff --git a/roles/firewall/templates/iptables.j2 b/roles/firewall/templates/iptables.j2 index 57f88fe..1a67d72 100644 --- a/roles/firewall/templates/iptables.j2 +++ b/roles/firewall/templates/iptables.j2 @@ -66,7 +66,7 @@ -A INPUT -i lo -m comment --comment "lo accept all" -j ACCEPT {% if firewall_ssh_whitelist | length %} -{% for ip in firewall_ssh_whitelist | ipv4 %} +{% for ip in firewall_ssh_whitelist | ansible.utils.ipv4 %} -A INPUT -p tcp -m tcp --dport 22 --source {{ ip }} -m comment --comment "accept {{ ip }} ssh 22/tcp" -j ACCEPT {% endfor %} {% endif %} @@ -94,7 +94,7 @@ -A INPUT -p icmp -m icmp --icmp-type echo-reply -m comment --comment "accept icmp echo-reply" -j ACCEPT {% if firewall_allowed_icmp_types | length %} -{% for type in firewall_allowed_icmp_types | ipv4 %} +{% for type in firewall_allowed_icmp_types | ansible.utils.ipv4 %} -A INPUT -p icmp -m icmp --icmp-type {{ type }} -m comment --comment "accept icmp {{ type }}" -j ACCEPT {% endfor %} {% endif %} diff --git a/roles/network/templates/netcfg.yaml.j2 b/roles/network/templates/netcfg.yaml.j2 index afdad76..6424031 100644 --- a/roles/network/templates/netcfg.yaml.j2 +++ b/roles/network/templates/netcfg.yaml.j2 @@ -31,7 +31,7 @@ network: {% if ansible_default_ipv4.address is defined or ansible_default_ipv6.address is defined %} addresses: {% if ansible_default_ipv4.address is defined %} - - {{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ipaddr('prefix') }} + - {{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('prefix') }} {% endif %} {% if ansible_default_ipv6.address is defined %} - {{ ansible_default_ipv6.address }}/{{ ansible_default_ipv6.prefix }} diff --git a/roles/network/templates/systemd-network.j2 b/roles/network/templates/systemd-network.j2 index b29883b..b1630a1 100644 --- a/roles/network/templates/systemd-network.j2 +++ b/roles/network/templates/systemd-network.j2 @@ -25,7 +25,7 @@ Name={{ ansible_default_ipv4.interface }} {% if ansible_default_ipv4.address is defined or ansible_default_ipv6.address is defined %} [Network] {% if ansible_default_ipv4.address is defined %} -Address={{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ipaddr('prefix') }} +Address={{ ansible_default_ipv4.address }}/{{ (ansible_default_ipv4.network + "/" + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('prefix') }} {% endif %} {% if ansible_default_ipv6.address is defined %} Address={{ ansible_default_ipv6.address }}/{{ ansible_default_ipv6.prefix }}