Skip to content

Commit 6c0faa0

Browse files
authored
Merge branch 'master' into fix/tls-san-api-endpoint
2 parents 8068ce6 + fad5c05 commit 6c0faa0

8 files changed

Lines changed: 43 additions & 13 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ It is also recommended that all managed nodes disable firewalls and swap. See [K
3838
$ ansible-galaxy collection install git+https://github.com/k3s-io/k3s-ansible.git
3939
```
4040

41+
Alternatively, add it to the [`requirement.yaml` file of your Ansible project](https://docs.ansible.com/ansible/latest/collections_guide/collections_installing.html#install-multiple-collections-with-a-requirements-file) as follows:
42+
43+
```yaml
44+
collections:
45+
- name: https://github.com/k3s-io/k3s-ansible.git
46+
type: git
47+
version: <comit-ish>
48+
```
49+
50+
As a comit-ish, you can use a branch, a version tag, or a specific commit.
51+
4152
### From source
4253
4354
Alternatively to an installation with `ansible-galaxy`, the `k3s-ansible` repository can simply be cloned from github:

inventory-sample.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

roles/k3s_agent/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ k3s_server_location: "/var/lib/rancher/k3s" # noqa var-naming[no-role-prefix]
44
systemd_dir: "/etc/systemd/system" # noqa var-naming[no-role-prefix]
55
api_port: 6443 # noqa var-naming[no-role-prefix]
66
extra_agent_args: "" # noqa var-naming[no-role-prefix]
7+
extra_install_envs: {} # noqa var-naming[no-role-prefix]

roles/k3s_agent/tasks/main.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@
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: Compute final agent arguments

roles/k3s_server/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ server_group: server # noqa var-naming[no-role-prefix]
99
agent_group: agent # noqa var-naming[no-role-prefix]
1010
use_external_database: false # noqa var-naming[no-role-prefix]
1111
extra_server_args: "" # noqa var-naming[no-role-prefix]
12+
extra_install_envs: {} # noqa var-naming[no-role-prefix]

roles/k3s_server/tasks/main.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@
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

roles/k3s_upgrade/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
systemd_dir: /etc/systemd/system # noqa var-naming[no-role-prefix]
33
server_group: server # noqa var-naming[no-role-prefix]
44
agent_group: agent # noqa var-naming[no-role-prefix]
5+
extra_install_envs: {} # noqa var-naming[no-role-prefix]

roles/k3s_upgrade/tasks/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@
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

0 commit comments

Comments
 (0)