2022-10-30 15:53:04 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: set k3s download suffix
|
|
|
|
set_fact:
|
|
|
|
k3s_suffix: "{{ k3s_suffix_lookup[ansible_architecture] }}"
|
|
|
|
|
2022-10-30 16:46:05 +01:00
|
|
|
- name: create k3s opt directory
|
|
|
|
file:
|
|
|
|
path: /opt/k3s
|
|
|
|
state: directory
|
|
|
|
|
2022-10-30 15:53:04 +01:00
|
|
|
- name: download k3s binary
|
|
|
|
get_url:
|
|
|
|
url: "{{ k3s_download_base_url }}/k3s{{ k3s_suffix }}"
|
2022-10-30 16:46:05 +01:00
|
|
|
dest: /opt/k3s/k3s
|
2022-10-30 15:53:04 +01:00
|
|
|
checksum: "sha256:{{ k3s_download_base_url }}/sha256sum{{ k3s_suffix }}.txt"
|
|
|
|
mode: '0755'
|
|
|
|
|
|
|
|
- name: create k3s symlinks
|
|
|
|
file:
|
|
|
|
state: link
|
2022-10-30 16:46:05 +01:00
|
|
|
src: /opt/k3s/k3s
|
2022-10-30 15:53:04 +01:00
|
|
|
dest: "/usr/local/bin/{{ item }}"
|
|
|
|
loop:
|
2022-10-30 16:46:05 +01:00
|
|
|
- k3s
|
2022-10-30 15:53:04 +01:00
|
|
|
- kubectl
|
|
|
|
- crictl
|
|
|
|
- ctr
|
|
|
|
|
|
|
|
- name: create /etc/rancher/k3s directory
|
|
|
|
file:
|
|
|
|
path: /etc/rancher/k3s
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: create k3s.env
|
|
|
|
file:
|
|
|
|
state: touch
|
|
|
|
path: /etc/rancher/k3s/k3s.env
|
|
|
|
mode: '0600'
|
|
|
|
modification_time: preserve
|
|
|
|
access_time: preserve
|
|
|
|
|
|
|
|
- name: copy service file
|
|
|
|
copy:
|
|
|
|
src: init.d/k3s
|
|
|
|
dest: /etc/init.d
|
|
|
|
mode: '0755'
|
|
|
|
when: ansible_distribution == "Alpine"
|
|
|
|
|
|
|
|
- name: enable and start k3s
|
|
|
|
service:
|
|
|
|
name: k3s
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
when: ansible_distribution == "Alpine"
|
|
|
|
|
|
|
|
- name: add cgroup options cmdline.txt
|
|
|
|
replace:
|
|
|
|
path: /media/mmcblk0p1/cmdline.txt
|
|
|
|
regexp: '^([\w](?!.*\b{{ item }}\b).*)$'
|
|
|
|
replace: '\1 {{ item }}'
|
|
|
|
loop:
|
|
|
|
- "cgroup_memory=1"
|
|
|
|
- "cgroup_enable=memory"
|
|
|
|
- "cgroup_enable=cpuset"
|
|
|
|
|
|
|
|
- name: add k3s files to lbu
|
|
|
|
lbu:
|
|
|
|
include:
|
|
|
|
- /usr/local/bin/k3s
|
|
|
|
- /usr/local/bin/kubectl
|
|
|
|
- /usr/local/bin/crictl
|
|
|
|
- /usr/local/bin/ctr
|
|
|
|
- /etc/init.d/k3s
|
|
|
|
when: ansible_distribution == "Alpine" and alpine_mode in ["diskless", "data"]
|