2019-12-21 18:11:30 +01:00
|
|
|
---
|
|
|
|
|
2020-01-11 13:31:23 +01:00
|
|
|
- name: Check the conditions when a single controller is defined
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.assert:
|
2019-12-21 18:11:30 +01:00
|
|
|
that:
|
2020-12-21 20:14:52 +01:00
|
|
|
- (k3s_controller_list | length == 1)
|
2021-02-16 16:46:01 +01:00
|
|
|
- ("datastore-endpoint" not in k3s_runtime_config or not k3s_runtime_config['datastore-endpoint'])
|
|
|
|
- (k3s_etcd_datastore is not defined or not k3s_etcd_datastore)
|
2020-01-11 13:31:23 +01:00
|
|
|
success_msg: "Control plane configuration is valid."
|
2021-02-28 17:45:38 +01:00
|
|
|
fail_msg: >-
|
|
|
|
Control plane configuration is invalid.
|
|
|
|
Please see notes about k3s_control_node and HA in README.md.
|
2021-02-16 16:46:01 +01:00
|
|
|
when:
|
|
|
|
- k3s_controller_list | length == 1
|
|
|
|
- not k3s_use_unsupported_config
|
|
|
|
- k3s_control_node
|
2020-01-11 13:31:23 +01:00
|
|
|
|
|
|
|
- name: Check the conditions when multiple controllers are defined
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.assert:
|
2020-01-11 13:31:23 +01:00
|
|
|
that:
|
2020-12-21 20:14:52 +01:00
|
|
|
- (k3s_controller_list | length >= 2)
|
2021-02-16 16:46:01 +01:00
|
|
|
- (("datastore-endpoint" in k3s_runtime_config and k3s_runtime_config['datastore-endpoint'])
|
|
|
|
or (k3s_etcd_datastore is defined and k3s_etcd_datastore))
|
2020-01-11 13:31:23 +01:00
|
|
|
success_msg: "Control plane configuration is valid."
|
2021-02-28 17:45:38 +01:00
|
|
|
fail_msg: >-
|
|
|
|
Control plane configuration is invalid. Please see notes about
|
|
|
|
k3s_control_node and HA in README.md.
|
2021-02-16 16:46:01 +01:00
|
|
|
when:
|
|
|
|
- k3s_controller_list | length >= 2
|
|
|
|
- k3s_control_node
|
2020-09-21 20:38:51 +02:00
|
|
|
|
|
|
|
- name: Check the conditions when embedded etcd is defined
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.assert:
|
2020-09-21 20:38:51 +02:00
|
|
|
that:
|
2020-12-21 20:14:52 +01:00
|
|
|
- (k3s_controller_list | length >= 3)
|
2021-02-16 16:46:01 +01:00
|
|
|
- (((k3s_controller_list | length) % 2) == 1)
|
2020-09-21 20:38:51 +02:00
|
|
|
success_msg: "Control plane configuration is valid."
|
2021-02-28 17:45:38 +01:00
|
|
|
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
|
2021-02-16 16:46:01 +01:00
|
|
|
when:
|
|
|
|
- k3s_etcd_datastore is defined
|
|
|
|
- k3s_etcd_datastore
|
|
|
|
- not k3s_use_unsupported_config
|
|
|
|
- k3s_control_node
|
fix: do ignore etcd member count when uninstalling
Otherwise, when completely uninstalling the etcd-enabled cluster, it fails with:
```
TASK [xanmanning.k3s : Check the conditions when embedded etcd is defined] ***************************************
fatal: [vm0]: FAILED! => {
"assertion": "(((k3s_controller_list | length) % 2) == 1)",
"changed": false,
"evaluated_to": false,
"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"
}
fatal: [vm1]: FAILED! => {
"assertion": "(((k3s_controller_list | length) % 2) == 1)",
"changed": false,
"evaluated_to": false,
"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"
}
fatal: [vm2]: FAILED! => {
"assertion": "(((k3s_controller_list | length) % 2) == 1)",
"changed": false,
"evaluated_to": false,
"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"
}
```
2021-07-21 13:56:09 +02:00
|
|
|
- k3s_state != 'uninstalled'
|