-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.yml
More file actions
41 lines (35 loc) · 1.19 KB
/
Copy pathinstall.yml
File metadata and controls
41 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- name: Download and run the k3s install script
ansible.builtin.shell: curl -sfL {{ k3s_install_url }} | sh -
args:
creates: /usr/local/bin/k3s # skip if the binary already exists (idempotent)
- name: Ensure k3s is running and enabled on boot
ansible.builtin.systemd:
name: k3s
state: started
enabled: true
- name: Wait for kubeconfig to be generated
ansible.builtin.wait_for:
path: /etc/rancher/k3s/k3s.yaml
state: present
timeout: 60 # on a fresh install, k3s needs a moment after start to write this file
- name: Query node status
ansible.builtin.command: k3s kubectl get nodes
register: k3s_nodes
changed_when: false # read-only query, never a change
- name: Print node status
ansible.builtin.debug:
msg: "{{ k3s_nodes.stdout_lines }}"
- name: Create the .kube directory
ansible.builtin.file:
path: "/home/{{ k3s_user }}/.kube"
state: directory
owner: "{{ k3s_user }}"
mode: "0755"
- name: Copy kubeconfig to the regular user
ansible.builtin.copy:
src: /etc/rancher/k3s/k3s.yaml
dest: "/home/{{ k3s_user }}/.kube/config"
owner: "{{ k3s_user }}"
mode: "0600" # contains credentials, owner read/write only
remote_src: true