Skip to content

Commit ce90ab0

Browse files
committed
Merge branch 'feature/k3s-ansible-init' into feature/k3s-monitoring
2 parents e5dff96 + 904df8a commit ce90ab0

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
k3s_version: "v1.31.0+k3s1" # Warning: changes to this variable won't be reflected in the cluster/image if k3s is already installed
1+
# Warning: changes to these variables won't be reflected in the cluster/image if k3s is already installed
2+
k3s_version: "v1.31.0+k3s1"
3+
k3s_selinux_release: v1.6.latest.1
4+
k3s_selinux_rpm_version: 1.6-1
5+
rocky_version: "{{ ansible_distribution_major_version }}"

ansible/roles/k3s/tasks/main.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
---
22

3-
- name: Check for existing k3s binaries
3+
- name: Check for existing k3s installation
44
stat:
5-
path: /usr/bin/k3s
5+
path: /var/lib/rancher/k3s
66
register: stat_result
77

8-
- name: Download and install k3s
8+
- name: Download and air-gapped installation of k3s
99
when: not stat_result.stat.exists
1010
block:
11+
12+
- name: Download k3s binary
13+
ansible.builtin.get_url:
14+
url: "https://github.com/k3s-io/k3s/releases/download/{{ k3s_version | urlencode }}/k3s"
15+
dest: /usr/bin/k3s
16+
owner: root
17+
group: root
18+
mode: "0755"
19+
20+
- name: Install k3s SELinux policy package
21+
yum:
22+
name: "https://github.com/k3s-io/k3s-selinux/releases/download/{{ k3s_selinux_release }}/k3s-selinux-{{ k3s_selinux_rpm_version }}.el{{ rocky_version }}.noarch.rpm"
23+
disable_gpg_check: true
24+
25+
- name: Create image directory
26+
ansible.builtin.file:
27+
path: "/var/lib/rancher/k3s/agent/images"
28+
state: directory
29+
30+
- name: Install k3s' internal images
31+
ansible.builtin.get_url:
32+
url: "https://github.com/k3s-io/k3s/releases/download/{{ k3s_version | urlencode }}/k3s-airgap-images-amd64.tar.zst"
33+
dest: /var/lib/rancher/k3s/agent/images/k3s-airgap-images-amd64.tar.zst
34+
1135
- name: Download k3s install script
1236
ansible.builtin.get_url:
1337
url: https://get.k3s.io/
@@ -26,6 +50,7 @@
2650
INSTALL_K3S_SKIP_START: "true"
2751
INSTALL_K3S_SKIP_ENABLE: "true"
2852
INSTALL_K3S_BIN_DIR: "/usr/bin"
53+
INSTALL_K3S_SKIP_DOWNLOAD: "true"
2954
changed_when: true
3055
loop:
3156
- server --disable=traefik --node-label clusterrole=server

0 commit comments

Comments
 (0)