mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-12-04 18:30:18 +01:00
Pre-FQCN breakage
This commit is contained in:
parent
3d2b74c816
commit
35b037c7ee
10 changed files with 41 additions and 13 deletions
|
@ -41,6 +41,9 @@ k3s_use_experimental: false
|
|||
# Allow for unsupported configurations in k3s?
|
||||
k3s_use_unsupported_config: false
|
||||
|
||||
# Enable etcd embedded datastore (EXPERIMENTAL)
|
||||
k3s_etcd_datastore: false
|
||||
|
||||
|
||||
##
|
||||
# Server Configuration
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
vars:
|
||||
molecule_is_test: true
|
||||
k3s_install_hard_links: true
|
||||
k3s_release_version: latest
|
||||
roles:
|
||||
- role: xanmanning.k3s
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
molecule_is_test: true
|
||||
k3s_release_version: latest
|
||||
k3s_use_experimental: true
|
||||
k3s_etcd_datastore: true
|
||||
k3s_server:
|
||||
cluster-init: true
|
||||
secrets-encryption: true
|
||||
pre_tasks:
|
||||
- name: Set each node to be a control node
|
||||
|
|
|
@ -78,9 +78,11 @@
|
|||
- name: Ensure k3s_runtime_config is set for control plane
|
||||
set_fact:
|
||||
k3s_runtime_config: "{{ (k3s_server | default('None')) | combine (k3s_agent | default('None')) }}"
|
||||
when: k3s_control_node is defined and k3s_control_node
|
||||
when: k3s_server is defined
|
||||
and (k3s_control_node is defined and k3s_control_node)
|
||||
|
||||
- name: Ensure k3s_runtime_config is set for agents
|
||||
set_fact:
|
||||
k3s_runtime_config: "{{ k3s_agent | default('None') }}"
|
||||
when: k3s_control_node is not defined or not k3s_control_node
|
||||
when: k3s_agent is defined
|
||||
and (k3s_control_node is not defined or not k3s_control_node)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
- k3s_use_experimental is defined and k3s_use_experimental
|
||||
success_msg: "Experimental variables are defined and enabled."
|
||||
fail_msg: "Experimental variables have been configured. If you want to use them ensure you set k3s_use_experimental"
|
||||
when: ("rootless" in k3s_runtime_config and k3s_runtime_config.rootless)
|
||||
or ("etcd-datastore" in k3s_runtime_config and k3s_runtime_config.etcd-datastore)
|
||||
or ("secrets-encryption" in k3s_runtime_config and k3s_runtime_config.secrets-encryption)
|
||||
or ("selinux" in k3s_runtime_config and k3s_runtime_config.selinux)
|
||||
when: ("rootless" in k3s_runtime_config and k3s_runtime_config['rootless'])
|
||||
or (k3s_etcd_datastore is defined and k3s_etcd_datastore)
|
||||
or ("secrets-encryption" in k3s_runtime_config and k3s_runtime_config['secrets-encryption'])
|
||||
or ("selinux" in k3s_runtime_config and k3s_runtime_config['selinux'])
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
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)
|
||||
and ("datastore-endpoint" not in k3s_runtime_config or not k3s_runtime_config['datastore-endpoint'])
|
||||
and (k3s_etcd_datastore is not defined or not k3s_etcd_datastore)
|
||||
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
|
||||
|
@ -15,8 +15,8 @@
|
|||
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))
|
||||
and (("datastore-endpoint" in k3s_runtime_config and k3s_runtime_config['datastore-endpoint'])
|
||||
or (k3s_etcd_datastore is defined and k3s_etcd_datastore))
|
||||
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
|
||||
|
@ -28,6 +28,6 @@
|
|||
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
|
||||
when: k3s_etcd_datastore is defined
|
||||
and k3s_etcd_datastore
|
||||
and not k3s_use_unsupported_config
|
||||
|
|
|
@ -7,5 +7,13 @@
|
|||
success_msg: "{{ k3s_release_version }} is supported by this role."
|
||||
fail_msg: "{{ k3s_release_version }} is not supported by this role, please use xanmanning.k3s v1.x."
|
||||
|
||||
- name: Check configuration in k3s_server and k3s_agent
|
||||
assert:
|
||||
that:
|
||||
- (item.setting not in k3s_runtime_config)
|
||||
success_msg: "{{ item.setting }} not found in server/agent config"
|
||||
fail_msg: "{{ item.setting }} found in server/agent config. Please set {{ item.correction }} to use this option."
|
||||
loop: "{{ k3s_config_exclude }}"
|
||||
|
||||
# Due to the v2 role now only supporting k3s v1.19+ - this file is intentionlly
|
||||
# blank until new configuration options are added.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
---
|
||||
|
||||
{% if k3s_etcd_datastore and (k3s_control_node is defined and k3s_control_node) and (k3s_primary_control_node is defined and k3s_primary_control_node) %}
|
||||
cluster-init: true
|
||||
{% endif %}
|
||||
{% if k3s_runtime_config is defined and k3s_runtime_config | length > 0 %}
|
||||
{{ k3s_runtime_config | to_nice_yaml(indent=2) }}
|
||||
{% endif %}
|
||||
|
|
|
@ -16,6 +16,10 @@ ExecStart={{ k3s_install_dir }}/k3s
|
|||
{% endif %}
|
||||
{% if k3s_control_node %}
|
||||
server
|
||||
{% if (k3s_etcd_datastore is defined and k3s_etcd_datastore) and (k3s_primary_control_node is not defined or not k3s_primary_control_node) %}
|
||||
--server https://{{ k3s_control_node_address }}:{{ k3s_runtime_config['https-listen-port'] | default(6443) }}
|
||||
--token-file {{ k3s_token_location }}/cluster-token
|
||||
{% endif %}
|
||||
{% if k3s_server is defined %}
|
||||
--config {{ k3s_config_file }}
|
||||
{% endif %}
|
||||
|
|
|
@ -65,3 +65,8 @@ k3s_token_location: "/etc/rancher"
|
|||
# Path for additional Kubernetes Manifests
|
||||
# https://rancher.com/docs/k3s/latest/en/advanced/#auto-deploying-manifests
|
||||
k3s_server_manifests_dir: /var/lib/rancher/k3s/server/manifests
|
||||
|
||||
# Items that should not appear in k3s_server or k3s_agent
|
||||
k3s_config_exclude:
|
||||
- setting: "cluster-init"
|
||||
correction: "k3s_etcd_datastore"
|
||||
|
|
Loading…
Reference in a new issue