File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ k3s_cluster:
2626 # Optional vars
2727 # extra_server_args: ""
2828 # extra_agent_args: ""
29+ # extra_install_envs: { 'INSTALL_K3S_SKIP_SELINUX_RPM': 'true' }
2930 # cluster_context: k3s-ansible
3031 # api_port: 6443
3132 # k3s_server_location: /var/lib/rancher/k3s
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ k3s_server_location: "/var/lib/rancher/k3s" # noqa var-naming[no-role-prefix]
44systemd_dir : " /etc/systemd/system" # noqa var-naming[no-role-prefix]
55api_port : 6443 # noqa var-naming[no-role-prefix]
66extra_agent_args : " " # noqa var-naming[no-role-prefix]
7+ extra_install_envs : {} # noqa var-naming[no-role-prefix]
Original file line number Diff line number Diff line change 2727 mode : " 0755"
2828
2929 - name : Download K3s binary
30- ansible.builtin.command :
30+ # For some reason, ansible-lint thinks using enviroment with command is an error
31+ # even though its valid https://ansible.readthedocs.io/projects/lint/rules/inline-env-var/#correct-code
32+ ansible.builtin.command : # noqa inline-env-var
3133 cmd : /usr/local/bin/k3s-install.sh
32- environment :
33- INSTALL_K3S_SKIP_START : " true"
34- INSTALL_K3S_VERSION : " {{ k3s_version }}"
35- INSTALL_K3S_EXEC : " agent"
34+ # Ensures that extra_install_envs are combined with required env vars
35+ environment : >-
36+ {{ extra_install_envs | combine({
37+ "INSTALL_K3S_SKIP_START": "true",
38+ "INSTALL_K3S_SYSTEMD_DIR": systemd_dir,
39+ "INSTALL_K3S_VERSION": k3s_version,
40+ "INSTALL_K3S_EXEC": "agent"
41+ }) }}
3642 changed_when : true
3743
3844- name : Setup optional config file
Original file line number Diff line number Diff line change @@ -9,3 +9,4 @@ server_group: server # noqa var-naming[no-role-prefix]
99agent_group : agent # noqa var-naming[no-role-prefix]
1010use_external_database : false # noqa var-naming[no-role-prefix]
1111extra_server_args : " " # noqa var-naming[no-role-prefix]
12+ extra_install_envs : {} # noqa var-naming[no-role-prefix]
Original file line number Diff line number Diff line change 2727 mode : " 0755"
2828
2929 - name : Download K3s binary
30- ansible.builtin.command :
30+ # For some reason, ansible-lint thinks using enviroment with command is an error
31+ # even though its valid https://ansible.readthedocs.io/projects/lint/rules/inline-env-var/#correct-code
32+ ansible.builtin.command : # noqa inline-env-var
3133 cmd : /usr/local/bin/k3s-install.sh
32- environment :
33- INSTALL_K3S_SKIP_START : " true"
34- INSTALL_K3S_VERSION : " {{ k3s_version }}"
34+ # Ensures that extra_install_envs are combined with required env vars
35+ environment : >-
36+ {{ extra_install_envs | combine({
37+ "INSTALL_K3S_SKIP_START": "true",
38+ "INSTALL_K3S_VERSION": k3s_version,
39+ }) }}
3540 changed_when : true
3641
3742- name : Add K3s autocomplete to user bashrc
Original file line number Diff line number Diff line change 22systemd_dir : /etc/systemd/system # noqa var-naming[no-role-prefix]
33server_group : server # noqa var-naming[no-role-prefix]
44agent_group : agent # noqa var-naming[no-role-prefix]
5+ extra_install_envs : {} # noqa var-naming[no-role-prefix]
Original file line number Diff line number Diff line change 3333 loop : " {{ k3s_service_files.files }}"
3434
3535 - name : Install new K3s Version
36- ansible.builtin.command :
36+ # For some reason, ansible-lint thinks using enviroment with command is an error
37+ # even though its valid https://ansible.readthedocs.io/projects/lint/rules/inline-env-var/#correct-code
38+ ansible.builtin.command : # noqa inline-env-var
3739 cmd : /usr/local/bin/k3s-install.sh
38- environment :
39- INSTALL_K3S_SKIP_START : " true"
40- INSTALL_K3S_VERSION : " {{ k3s_version }}"
40+ environment : >-
41+ {{ extra_install_envs | combine({
42+ "INSTALL_K3S_SKIP_START": "true",
43+ "INSTALL_K3S_VERSION": k3s_version,
44+ }) }}
4145 changed_when : true
4246
4347 - name : Restore K3s service
You can’t perform that action at this time.
0 commit comments