xoxys.k3s/tasks/prepare.yml

70 lines
1.7 KiB
YAML

---
- block:
- name: Import Rancher public key
rpm_key:
state: present
key: https://rpm.rancher.io/public.key
- name: Ensure dependencies are installed
package:
name: "{{ item }}"
state: present
loop: "{{ k3s_packages_extra }}"
- name: Prepare directory structure
file:
path: "{{ item }}"
owner: root
group: root
mode: 0700
state: directory
loop:
- "{{ k3s_config_dir }}"
- "{{ k3s_config_dir }}/server"
- "{{ k3s_data_dir }}"
- "{{ k3s_log_dir }}"
- name: Download K3s binary
get_url:
url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s
checksum: sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-amd64.txt
dest: /usr/local/bin/k3s
owner: root
group: root
mode: 0755
- name: Copy K3s config file
template:
src: "etc/rancher/k3s/config.yaml.j2"
dest: "/etc/rancher/k3s/config.yaml"
owner: root
group: root
mode: 0600
notify: __k3s_restart
- name: Copy K3s server config files
template:
src: "etc/rancher/k3s/server/{{ item }}.j2"
dest: "/etc/rancher/k3s/server/{{ item }}"
owner: root
group: root
mode: 0600
loop:
- admission-config.yaml
when: k3s_server | bool
notify: __k3s_restart
- name: Create kubectl symlink
file:
src: /usr/local/bin/k3s
dest: /usr/local/bin/kubectl
state: link
- name: Create crictl symlink
file:
src: /usr/local/bin/k3s
dest: /usr/local/bin/crictl
state: link
become: True
become_user: root