From f2a7181f990cf022cfee8a95035f50aab3689fa3 Mon Sep 17 00:00:00 2001 From: Wren Turkal Date: Sun, 14 Jun 2026 01:26:32 -0700 Subject: [PATCH] fix: make assert test for netaddr actually return a boolean (#13304) * fix: make assert test for netaddr actually return a boolean The netaddr test returns a string when the netaddr is installed. This makes Ansible 2.20 angry. Here's a fix to make sure the true case also returns a boolean instead of a string. * fix: more fixes for non-boolean conditions The `cloud_provider` assertion change is a little more involved. The only two allowed values are "" and "external". Let's just always check the assertion instead of skipping it when it's the default value, which is "". All the other changes should be fairly obvious. --- playbooks/ansible_version.yml | 2 +- roles/validate_inventory/tasks/main.yml | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/playbooks/ansible_version.yml b/playbooks/ansible_version.yml index 9dfdae8cc..605207bbc 100644 --- a/playbooks/ansible_version.yml +++ b/playbooks/ansible_version.yml @@ -21,7 +21,7 @@ - name: "Check that python netaddr is installed" assert: msg: "Python netaddr is not present" - that: "'127.0.0.1' | ansible.utils.ipaddr" + that: "'127.0.0.1' | ansible.utils.ipaddr == '127.0.0.1'" tags: - check diff --git a/roles/validate_inventory/tasks/main.yml b/roles/validate_inventory/tasks/main.yml index 4967657be..c05a1650e 100644 --- a/roles/validate_inventory/tasks/main.yml +++ b/roles/validate_inventory/tasks/main.yml @@ -19,13 +19,13 @@ - name: Stop if kube_control_plane group is empty assert: - that: groups.get( 'kube_control_plane' ) + that: groups.get( 'kube_control_plane' ) != [] run_once: true when: not ignore_assert_errors - name: Stop if etcd group is empty in external etcd mode assert: - that: groups.get('etcd') or etcd_deployment_type == 'kubeadm' + that: groups.get('etcd') != [] or etcd_deployment_type == 'kubeadm' fail_msg: "Group 'etcd' cannot be empty in external etcd mode" run_once: true when: @@ -79,9 +79,8 @@ - name: Check cloud_provider value assert: - that: cloud_provider == 'external' + that: cloud_provider in ["", 'external'] when: - - cloud_provider - not ignore_assert_errors - name: Check external_cloud_provider value @@ -94,7 +93,7 @@ - name: "Check that kube_service_addresses is a network range" assert: that: - - kube_service_addresses | ansible.utils.ipaddr('net') + - kube_service_addresses | ansible.utils.ipaddr('net') is not false msg: "kube_service_addresses = '{{ kube_service_addresses }}' is not a valid network range" run_once: true when: ipv4_stack | bool @@ -102,7 +101,7 @@ - name: "Check that kube_pods_subnet is a network range" assert: that: - - kube_pods_subnet | ansible.utils.ipaddr('net') + - kube_pods_subnet | ansible.utils.ipaddr('net') is not false msg: "kube_pods_subnet = '{{ kube_pods_subnet }}' is not a valid network range" run_once: true when: ipv4_stack | bool