From b370279dbc9b1334cc31378e78c9dfabacd84e0b Mon Sep 17 00:00:00 2001
From: Micah Anderson <micah@riseup.net>
Date: Fri, 2 Dec 2022 14:59:32 -0500
Subject: [PATCH] First pass at resolving ansible deprecation warnings:

. [defaults]callback_whitelist option, normalizing names to new standard, use
callbacks_enabled instead.
. Use 'ansible.utils.ipv4' module instead.
. Use 'ansible.utils.ipv6' module instead.
---
 float                                                |  2 +-
 .../templates/firewall/11net-overlay-raw.j2          |  4 ++--
 roles/float-base/templates/firewall/10float.j2       |  4 ++--
 .../templates/bind/named.conf.options                |  4 ++--
 roles/float-infra-dns/templates/dns/infra.yml        | 12 ++++++------
 roles/float-infra-dns/templates/zonetool.yml         |  4 ++--
 test-driver                                          |  2 +-
 7 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/float b/float
index f4a6fb23..450b4580 100755
--- a/float
+++ b/float
@@ -185,7 +185,7 @@ DEFAULT_VARS = {
 
             'nocows': 1,
             'display_skipped_hosts': False,
-            'callback_whitelist': 'float_ci',
+            'callbacks_enabled': 'float_ci',
             'stdout_callback': 'float_ci',
             'host_key_checking': False,
             'forks': 50,
diff --git a/roles/float-base-net-overlay/templates/firewall/11net-overlay-raw.j2 b/roles/float-base-net-overlay/templates/firewall/11net-overlay-raw.j2
index 45263432..b8fb718d 100644
--- a/roles/float-base-net-overlay/templates/firewall/11net-overlay-raw.j2
+++ b/roles/float-base-net-overlay/templates/firewall/11net-overlay-raw.j2
@@ -1,8 +1,8 @@
 {% macro allow_host_ips(h, chain) %}
-{% for ip in hostvars[h]['ips'] | ansible.netcommon.ipv4 | sort %}
+{% for ip in hostvars[h]['ips'] | ansible.utils.ipv4 | sort %}
 add_rule4 -A {{ chain }} -s {{ ip }} -j CT --notrack
 {% endfor %}
-{% for ip in hostvars[h]['ips'] | ansible.netcommon.ipv6 | sort %}
+{% for ip in hostvars[h]['ips'] | ansible.utils.ipv6 | sort %}
 add_rule6 -A {{ chain }} -s {{ ip }} -j CT --notrack
 {% endfor %}
 {% endmacro %}
diff --git a/roles/float-base/templates/firewall/10float.j2 b/roles/float-base/templates/firewall/10float.j2
index e8888a41..48c88943 100644
--- a/roles/float-base/templates/firewall/10float.j2
+++ b/roles/float-base/templates/firewall/10float.j2
@@ -2,10 +2,10 @@
 # specific sets of hosts.
 
 {% macro allow_host_ips(h, chain) %}
-{% for ip in hostvars[h]['ips'] | ansible.netcommon.ipv4 | sort %}
+{% for ip in hostvars[h]['ips'] | ansible.utils.ipv4 | sort %}
 add_rule4 -A {{ chain }} -s {{ ip }} -j ACCEPT
 {% endfor %}
-{% for ip in hostvars[h]['ips'] | ansible.netcommon.ipv6 | sort %}
+{% for ip in hostvars[h]['ips'] | ansible.utils.ipv6 | sort %}
 add_rule6 -A {{ chain }} -s {{ ip }} -j ACCEPT
 {% endfor %}
 {% endmacro %}
diff --git a/roles/float-infra-dns/templates/bind/named.conf.options b/roles/float-infra-dns/templates/bind/named.conf.options
index fb34501e..906f1094 100644
--- a/roles/float-infra-dns/templates/bind/named.conf.options
+++ b/roles/float-infra-dns/templates/bind/named.conf.options
@@ -10,7 +10,7 @@ options {
 {% if float_limit_bind_to_known_interfaces | default(False) %}
   listen-on {
     127.0.0.1;
-{% for ip in ips | ansible.netcommon.ipv4 | sort %}
+{% for ip in ips | ansible.utils.ipv4 | sort %}
     {{ ip }};
 {% endfor %}
 {% for n in net_overlays | sort if ('ip_' + n.name) in hostvars[inventory_hostname] %}
@@ -19,7 +19,7 @@ options {
   };
   listen-on-v6 {
     ::1;
-{% for ip in ips | ansible.netcommon.ipv6 | sort %}
+{% for ip in ips | ansible.utils.ipv6 | sort %}
     {{ ip }};
 {% endfor %}
   };
diff --git a/roles/float-infra-dns/templates/dns/infra.yml b/roles/float-infra-dns/templates/dns/infra.yml
index b104d31b..8591f01e 100644
--- a/roles/float-infra-dns/templates/dns/infra.yml
+++ b/roles/float-infra-dns/templates/dns/infra.yml
@@ -3,8 +3,8 @@
 "@ns":
   _:
 {% for h in services['dns'].hosts | sort %}
-{% set host_ip4 = hostvars[h]['public_ips'] | ansible.netcommon.ipv4 %}
-{% set host_ip6 = hostvars[h]['public_ips'] | ansible.netcommon.ipv6 %}
+{% set host_ip4 = hostvars[h]['public_ips'] | ansible.utils.ipv4 %}
+{% set host_ip6 = hostvars[h]['public_ips'] | ansible.utils.ipv6 %}
 {% if host_ip4 %}
     - NS ns{{ loop.index }}.{{ mx_ns_domain }}.
 {% endif %}
@@ -32,8 +32,8 @@
   # The explicit NS delegation for 'l' is necessary for dnssec-sign to work properly.
   l:
 {% for h in services['dns'].hosts | sort %}
-{% set host_ip4 = hostvars[h]['public_ips'] | ansible.netcommon.ipv4 %}
-{% set host_ip6 = hostvars[h]['public_ips'] | ansible.netcommon.ipv6 %}
+{% set host_ip4 = hostvars[h]['public_ips'] | ansible.utils.ipv4 %}
+{% set host_ip6 = hostvars[h]['public_ips'] | ansible.utils.ipv6 %}
 {% if host_ip4 %}
     - NS ns{{ loop.index }}.{{ mx_ns_domain }}.
 {% endif %}
@@ -45,8 +45,8 @@
 {% if d == mx_ns_domain %}
 {# Only generate the nameservers' A records on the chosen zone #}
 {% for h in services['dns'].hosts | sort %}
-{% set host_ip4 = hostvars[h]['public_ips'] | ansible.netcommon.ipv4 %}
-{% set host_ip6 = hostvars[h]['public_ips'] | ansible.netcommon.ipv6 %}
+{% set host_ip4 = hostvars[h]['public_ips'] | ansible.utils.ipv4 %}
+{% set host_ip6 = hostvars[h]['public_ips'] | ansible.utils.ipv6 %}
 {% if host_ip4 %}
   ns{{ loop.index }}: {{ host_ip4 | to_json }}
 {% endif %}
diff --git a/roles/float-infra-dns/templates/zonetool.yml b/roles/float-infra-dns/templates/zonetool.yml
index 4f6fcbd0..b80c198d 100644
--- a/roles/float-infra-dns/templates/zonetool.yml
+++ b/roles/float-infra-dns/templates/zonetool.yml
@@ -1,6 +1,6 @@
 ---
 {% set all_ips = services['frontend'].hosts | map('extract', hostvars) | rejectattr('traffic', 'false') | map(attribute='public_ips') | reject('undefined') | flatten %}
 
-FRONTENDS4: {{ all_ips | ansible.netcommon.ipv4 | list | to_json }}
+FRONTENDS4: {{ all_ips | ansible.utils.ipv4 | list | to_json }}
 
-FRONTENDS6: {{ all_ips | ansible.netcommon.ipv6 | list | to_json }}
+FRONTENDS6: {{ all_ips | ansible.utils.ipv6 | list | to_json }}
diff --git a/test-driver b/test-driver
index dcef19c1..863c7176 100755
--- a/test-driver
+++ b/test-driver
@@ -56,7 +56,7 @@ save_logs() {
     log "Saving logs from VMs (if any)"
     mkdir -p "${out_dir}"
     ANSIBLE_STDOUT_CALLBACK=null \
-    ${float_dir}/float run -e "callback_whitelist=" -e "out_dir=${out_dir}" \
+    ${float_dir}/float run -e "callbacks_enabled=" -e "out_dir=${out_dir}" \
         ${float_dir}/test/save-logs.yml
 }
 
-- 
GitLab