preinstall: fix checking that excluded host are cached (#11693)

- Lookup was not returning a list, making the difference filter spit out
  garbage -> query always return a list
- hostvars is a dictionnary, so convert to list before selectattr and
  map back to only get keys
pull/11695/head
Max Gautier 2024-11-07 11:27:33 +01:00 committed by GitHub
parent d23753e9f7
commit bf6687b032
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -1,10 +1,10 @@
--- ---
- 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 | selectattr('ansible_default_ipv4', 'undefined')).keys() }}" uncached_hosts: "{{ hostvars | dict2items | selectattr('value.ansible_default_ipv4', 'undefined') | map(attribute='key') }}"
excluded_hosts: "{{ hostvars.keys() | difference(lookup('inventory_hostnames', ansible_limit)) }}" excluded_hosts: "{{ hostvars.keys() | difference(query('inventory_hostnames', ansible_limit)) }}"
assert: assert:
that: uncached_hosts | intersect(excluded_hosts) == 0 that: uncached_hosts | intersect(excluded_hosts) == []
fail_msg: | fail_msg: |
Kubespray does not support '--limit' without a populated facts cache for the excluded hosts. Kubespray does not support '--limit' without a populated facts cache for the excluded hosts.
Please run the facts.yml playbook first without '--limit'. Please run the facts.yml playbook first without '--limit'.