Skip to content

Commit

Permalink
preinstall: fix checking that excluded host are cached (#11693)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
VannTen authored Nov 7, 2024
1 parent d23753e commit bf6687b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions roles/kubernetes/preinstall/tasks/0040-verify-settings.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: Stop if any host not in '--limit' does not have a fact cache
vars:
uncached_hosts: "{{ (hostvars | selectattr('ansible_default_ipv4', 'undefined')).keys() }}"
excluded_hosts: "{{ hostvars.keys() | difference(lookup('inventory_hostnames', ansible_limit)) }}"
uncached_hosts: "{{ hostvars | dict2items | selectattr('value.ansible_default_ipv4', 'undefined') | map(attribute='key') }}"
excluded_hosts: "{{ hostvars.keys() | difference(query('inventory_hostnames', ansible_limit)) }}"
assert:
that: uncached_hosts | intersect(excluded_hosts) == 0
that: uncached_hosts | intersect(excluded_hosts) == []
fail_msg: |
Kubespray does not support '--limit' without a populated facts cache for the excluded hosts.
Please run the facts.yml playbook first without '--limit'.
Expand Down

0 comments on commit bf6687b

Please sign in to comment.