53 lines
1.1 KiB
YAML
53 lines
1.1 KiB
YAML
|
---
|
||
|
|
||
|
- name: Enable IPv4 forwarding
|
||
|
sysctl:
|
||
|
name: net.ipv4.ip_forward
|
||
|
value: "1"
|
||
|
state: present
|
||
|
reload: true
|
||
|
|
||
|
- 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: 755
|
||
|
|
||
|
- name: Copy SystemD service
|
||
|
template:
|
||
|
src: k3s.service.j2
|
||
|
dest: /usr/lib/systemd/system/k3s.service
|
||
|
owner: root
|
||
|
mode: 644
|
||
|
|
||
|
- name: Enable k3s service
|
||
|
systemd:
|
||
|
name: k3s
|
||
|
daemon_reload: true
|
||
|
state: restarted
|
||
|
enabled: true
|
||
|
|
||
|
- name: Create kubectl symlink
|
||
|
file:
|
||
|
src: /usr/local/bin/k3s
|
||
|
dest: /usr/local/bin/kubectl
|
||
|
state: link
|
||
|
|
||
|
- name: Create directory .kube
|
||
|
file:
|
||
|
path: ~{{ ansible_user }}/.kube
|
||
|
state: directory
|
||
|
owner: "{{ ansible_user }}"
|
||
|
mode: "750"
|
||
|
|
||
|
- name: Copy config file to user home directory
|
||
|
copy:
|
||
|
src: /etc/rancher/k3s/k3s.yaml
|
||
|
dest: ~{{ ansible_user }}/.kube/config
|
||
|
remote_src: true
|
||
|
owner: "{{ ansible_user }}"
|
||
|
mode: "600"
|