2019-03-09 21:54:44 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure k3s control node fact is set
|
|
|
|
set_fact:
|
2020-05-16 21:18:10 +02:00
|
|
|
k3s_control_node: "{{ 'false' if k3s_build_cluster else 'true' }}"
|
2019-03-09 21:54:44 +01:00
|
|
|
when: k3s_control_node is not defined
|
|
|
|
|
2020-01-11 23:42:29 +01:00
|
|
|
- name: Ensure k3s master control node fact is set
|
|
|
|
set_fact:
|
2020-05-16 21:18:10 +02:00
|
|
|
k3s_primary_control_node: "{{ 'false' if k3s_build_cluster else 'true' }}"
|
2020-01-11 23:42:29 +01:00
|
|
|
when: k3s_primary_control_node is not defined
|
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
- name: Ensure a k3s control node is defined if none are found in play_hosts
|
|
|
|
block:
|
2020-05-16 21:18:10 +02:00
|
|
|
- name: Set the control host
|
2019-03-09 21:54:44 +01:00
|
|
|
set_fact:
|
|
|
|
k3s_control_node: true
|
|
|
|
when: inventory_hostname == play_hosts[0]
|
|
|
|
when: true not in (hostvars | json_query('*.k3s_control_node'))
|
2020-05-16 21:18:10 +02:00
|
|
|
and k3s_build_cluster is defined and k3s_build_cluster
|
2019-03-09 21:54:44 +01:00
|
|
|
|
|
|
|
- name: Ensure a count of control masters is generated
|
|
|
|
set_fact:
|
|
|
|
k3s_controller_count: "{{ k3s_controller_count + [ item ] }}"
|
2020-01-11 23:42:29 +01:00
|
|
|
when: hostvars[item].k3s_control_node
|
|
|
|
loop: "{{ play_hosts }}"
|
|
|
|
|
|
|
|
- name: Ensure a primary k3s control node is defined if multiple are found in play_hosts
|
|
|
|
set_fact:
|
|
|
|
k3s_primary_control_node: true
|
|
|
|
when: k3s_controller_count | length > 1
|
|
|
|
and inventory_hostname == k3s_controller_count[0]
|
2020-05-16 21:18:10 +02:00
|
|
|
and k3s_build_cluster is defined and k3s_build_cluster
|