Skip to content

Commit ab65245

Browse files
committed
added k3s installation to bootstrap
1 parent 513ad1c commit ab65245

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

ansible/bootstrap.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
---
22

3+
- hosts: k3s
4+
become: yes
5+
tasks:
6+
- name: Download k3s install script
7+
ansible.builtin.get_url:
8+
url: https://get.k3s.io/
9+
timeout: 120
10+
dest: /usr/local/bin/k3s-install.sh
11+
owner: root
12+
group: root
13+
mode: "0755"
14+
15+
- hosts: k3s_server
16+
become: yes
17+
tasks:
18+
- name: Install k3s server
19+
ansible.builtin.shell:
20+
cmd: /usr/local/bin/k3s-install.sh
21+
environment:
22+
INSTALL_K3S_VERSION: "v1.31.0+k3s1"
23+
INSTALL_K3S_EXEC: "server"
24+
INSTALL_K3S_SKIP_START: true
25+
changed_when: true
26+
27+
- hosts: k3s_agent
28+
become: yes
29+
tasks:
30+
- name: Install k3s agent
31+
ansible.builtin.shell:
32+
cmd: /usr/local/bin/k3s-install.sh
33+
environment:
34+
INSTALL_K3S_VERSION: "v1.31.0+k3s1"
35+
INSTALL_K3S_EXEC: "agent"
36+
INSTALL_K3S_SKIP_START: true
37+
changed_when: true
38+
39+
- hosts: k3s
40+
become: yes
41+
tasks:
42+
- name: Creating directory on root path
43+
ansible.builtin.file:
44+
path: /root/bin
45+
state: directory
46+
owner: root
47+
- name: Adding symlinks to k3s binaries for root
48+
ansible.builtin.file:
49+
src: /usr/local/bin/k3s
50+
dest: "/root/bin/{{ item }}"
51+
state: link
52+
owner: root
53+
with_items:
54+
- k3s
55+
- kubectl
56+
57+
358
- hosts: cluster
459
gather_facts: false
560
become: yes

environments/common/inventory/groups

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,17 @@ freeipa_client
134134
# Hosts to run TuneD configuration
135135

136136
[ansible_init]
137-
# Hosts to run linux-anisble-init
137+
# Hosts to run linux-anisble-init
138+
139+
[k3s_server]
140+
# Host to run k3s server
141+
control
142+
143+
[k3s_agent]
144+
# Hosts to run as k3s agents
145+
login
146+
compute
147+
148+
[k3s:children]
149+
k3s_server
150+
k3s_agent

0 commit comments

Comments
 (0)