Skip to content

Commit 8b7941d

Browse files
committed
fixed k3s install overwriting ansible-init changes
1 parent cfb5514 commit 8b7941d

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
k3s_version: "v1.31.0+k3s1"
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

ansible/roles/k3s/tasks/main.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
---
22

3-
- name: Download k3s install script
4-
ansible.builtin.get_url:
5-
url: https://get.k3s.io/
6-
timeout: 120
7-
dest: /usr/bin/k3s-install.sh
8-
owner: root
9-
group: root
10-
mode: "0755"
3+
- name: Check for existing k3s binaries
4+
stat:
5+
path: /usr/bin/k3s
6+
register: stat_result
7+
8+
- name: Download and install k3s
9+
when: not stat_result.stat.exists
10+
block:
11+
- name: Download k3s install script
12+
ansible.builtin.get_url:
13+
url: https://get.k3s.io/
14+
timeout: 120
15+
dest: /usr/bin/k3s-install.sh
16+
owner: root
17+
group: root
18+
mode: "0755"
1119

12-
- name: Install k3s
13-
ansible.builtin.shell:
14-
cmd: /usr/bin/k3s-install.sh
15-
environment:
16-
INSTALL_K3S_VERSION: "{{ k3s_version }}"
17-
INSTALL_K3S_EXEC: "{{ item }}"
18-
INSTALL_K3S_SKIP_START: "true"
19-
INSTALL_K3S_SKIP_ENABLE: "true"
20-
INSTALL_K3S_BIN_DIR: "/usr/bin"
21-
changed_when: true
22-
loop:
23-
- server
24-
- agent
20+
- name: Install k3s
21+
ansible.builtin.shell:
22+
cmd: /usr/bin/k3s-install.sh
23+
environment:
24+
INSTALL_K3S_VERSION: "{{ k3s_version }}"
25+
INSTALL_K3S_EXEC: "{{ item }}"
26+
INSTALL_K3S_SKIP_START: "true"
27+
INSTALL_K3S_SKIP_ENABLE: "true"
28+
INSTALL_K3S_BIN_DIR: "/usr/bin"
29+
changed_when: true
30+
loop:
31+
- server
32+
- agent
2533

2634
- name: Install helm
2735
unarchive:

0 commit comments

Comments
 (0)