From d173f1d9514ba9fad30310bfe65109e87345ed87 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Mon, 23 Dec 2024 08:48:10 +0100 Subject: [PATCH] Only consider host in 'k8s_cluster' when checking if ip is a cached fact (#11817) This avoids spurious failure with 'localhost'. It should also be more correct the inventory contains uncached hosts which are not in `k8s_cluster` and therefore should not be Kubespray business. (We still use hostvars for uncached hosts, because it's easier to select on 'ansible_default_ipv4' that way and does not change the end result) --- roles/kubernetes/preinstall/tasks/0040-verify-settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/kubernetes/preinstall/tasks/0040-verify-settings.yml b/roles/kubernetes/preinstall/tasks/0040-verify-settings.yml index e911c76cc..400020830 100644 --- a/roles/kubernetes/preinstall/tasks/0040-verify-settings.yml +++ b/roles/kubernetes/preinstall/tasks/0040-verify-settings.yml @@ -2,7 +2,7 @@ - name: Stop if any host not in '--limit' does not have a fact cache vars: uncached_hosts: "{{ hostvars | dict2items | selectattr('value.ansible_default_ipv4', 'undefined') | map(attribute='key') }}" - excluded_hosts: "{{ hostvars.keys() | difference(query('inventory_hostnames', ansible_limit)) }}" + excluded_hosts: "{{ groups['k8s_cluster'] | difference(query('inventory_hostnames', ansible_limit)) }}" assert: that: uncached_hosts | intersect(excluded_hosts) == [] fail_msg: |