mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-05-08 01:47:37 -02:30
Test group membership with group_names
Testing for group membership with group names makes Kubespray more tolerant towards the structure of the inventory. Where 'inventory_hostname in groups["some_group"] would fail if "some_group" is not defined, '"some_group" in group_names' would not.
This commit is contained in:
@@ -4,18 +4,18 @@
|
||||
with_items:
|
||||
- "{{ kube_router_annotations_master }}"
|
||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||
when: kube_router_annotations_master is defined and inventory_hostname in groups['kube_control_plane']
|
||||
when: kube_router_annotations_master is defined and 'kube_control_plane' in group_names
|
||||
|
||||
- name: Kube-router | Add annotations on kube_node
|
||||
command: "{{ kubectl }} annotate --overwrite node {{ ansible_hostname }} {{ item }}"
|
||||
with_items:
|
||||
- "{{ kube_router_annotations_node }}"
|
||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||
when: kube_router_annotations_node is defined and inventory_hostname in groups['kube_node']
|
||||
when: kube_router_annotations_node is defined and 'kube_node' in group_names
|
||||
|
||||
- name: Kube-router | Add common annotations on all servers
|
||||
command: "{{ kubectl }} annotate --overwrite node {{ ansible_hostname }} {{ item }}"
|
||||
with_items:
|
||||
- "{{ kube_router_annotations_all }}"
|
||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||
when: kube_router_annotations_all is defined and inventory_hostname in groups['k8s_cluster']
|
||||
when: kube_router_annotations_all is defined and 'k8s_cluster' in group_names
|
||||
|
||||
Reference in New Issue
Block a user