mirror of
https://github.com/PyratLabs/ansible-role-k3s.git
synced 2024-11-26 12:27:28 +01:00
26 lines
806 B
YAML
26 lines
806 B
YAML
---
|
|
|
|
- name: Ensure k3s control node fact is set
|
|
set_fact:
|
|
k3s_control_node: false
|
|
when: k3s_control_node is not defined
|
|
|
|
- name: Ensure a k3s control node is defined if none are found in play_hosts
|
|
block:
|
|
- name: Set control host
|
|
set_fact:
|
|
k3s_control_node: true
|
|
when: inventory_hostname == play_hosts[0]
|
|
when: true not in (hostvars | json_query('*.k3s_control_node'))
|
|
|
|
- name: Ensure a count of control masters is generated
|
|
set_fact:
|
|
k3s_controller_count: "{{ k3s_controller_count + [ item ] }}"
|
|
when: item
|
|
loop: "{{ hostvars | json_query('*.k3s_control_node') }}"
|
|
|
|
- name: Fail playbook if there are multiple controllers defined
|
|
fail:
|
|
msg: "Multiple controllers have been defined. This is not yet supported."
|
|
when: k3s_controller_count | length > 1
|