71 lines
1.5 KiB
YAML
71 lines
1.5 KiB
YAML
---
|
|
|
|
- name: set k3s download suffix
|
|
set_fact:
|
|
k3s_suffix: "{{ k3s_suffix_lookup[ansible_architecture] }}"
|
|
|
|
- name: download k3s binary
|
|
get_url:
|
|
url: "{{ k3s_download_base_url }}/k3s{{ k3s_suffix }}"
|
|
dest: /usr/local/bin/k3s
|
|
checksum: "sha256:{{ k3s_download_base_url }}/sha256sum{{ k3s_suffix }}.txt"
|
|
mode: '0755'
|
|
|
|
- name: create k3s symlinks
|
|
file:
|
|
state: link
|
|
src: /usr/local/bin/k3s
|
|
dest: "/usr/local/bin/{{ item }}"
|
|
loop:
|
|
- 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/rancher/k3s/k3s.env
|
|
- /etc/init.d/k3s
|
|
when: ansible_distribution == "Alpine" and alpine_mode in ["diskless", "data"]
|