ansible-role-k3s/tasks/validate/check-master-count.yml

33 lines
1.6 KiB
YAML

---
- name: Check the conditions when a single controller is defined
assert:
that:
- (k3s_controller_count | length == 1)
and ("datastore-endpoint" not in k3s_runtime_config or not k3s_runtime_config.datastore-endpoint)
and ("cluster-init" not in k3s_runtime_config or not k3s_runtime_config.cluster-init)
success_msg: "Control plane configuration is valid."
fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md."
when: k3s_controller_count | length == 1
and not k3s_use_unsupported_config
- name: Check the conditions when multiple controllers are defined
assert:
that:
- (k3s_controller_count | length >= 2)
and (("datastore-endpoint" in k3s_runtime_config and k3s_runtime_config.datastore-endpoint)
or ("cluster-init" in k3s_runtime_config and k3s_runtime_config.cluster-init))
success_msg: "Control plane configuration is valid."
fail_msg: "Control plane configuration is invalid. Please see notes about k3s_control_node and HA in README.md."
when: k3s_controller_count | length >= 2
- name: Check the conditions when embedded etcd is defined
assert:
that:
- (k3s_controller_count | length >= 3)
and (((k3s_controller_count | length) % 2) == 1)
success_msg: "Control plane configuration is valid."
fail_msg: "Etcd should have a minimum of 3 defined members and the number of members should be odd. Please see notes about HA in README.md"
when: ("cluster-init" in k3s_runtime_config)
and k3s_runtime_config.cluster-init
and not k3s_use_unsupported_config