mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2025-12-14 13:54:37 +03:00
Assert correct limit usage
This should prevent confusing errors with undefined variables
This commit is contained in:
@@ -1,4 +1,19 @@
|
|||||||
---
|
---
|
||||||
|
- 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)) }}"
|
||||||
|
assert:
|
||||||
|
that: uncached_hosts | intersect(excluded_hosts) == 0
|
||||||
|
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'.
|
||||||
|
The following excluded hosts are not cached: {{ uncached_hosts | intersect(excluded_hosts) }}
|
||||||
|
run_once: true
|
||||||
|
when:
|
||||||
|
- ansible_limit is defined
|
||||||
|
- not ignore_assert_errors
|
||||||
|
|
||||||
- name: Stop if kube_control_plane group is empty
|
- name: Stop if kube_control_plane group is empty
|
||||||
assert:
|
assert:
|
||||||
that: groups.get( 'kube_control_plane' )
|
that: groups.get( 'kube_control_plane' )
|
||||||
|
|||||||
Reference in New Issue
Block a user