Browse Source

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)
pull/11827/head
Max Gautier 3 months ago
committed by GitHub
parent
commit
d173f1d951
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions
  1. 2
      roles/kubernetes/preinstall/tasks/0040-verify-settings.yml

2
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 - name: Stop if any host not in '--limit' does not have a fact cache
vars: vars:
uncached_hosts: "{{ hostvars | dict2items | selectattr('value.ansible_default_ipv4', 'undefined') | map(attribute='key') }}" 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: assert:
that: uncached_hosts | intersect(excluded_hosts) == [] that: uncached_hosts | intersect(excluded_hosts) == []
fail_msg: | fail_msg: |

Loading…
Cancel
Save