1
0
Fork 0
home-stack-ansible/roles/k3s-server/tasks/main.yml

62 lines
1.4 KiB
YAML
Raw Normal View History

2021-08-25 04:33:56 +00:00
- name: Copy k3s service file
register: k3s_service
template:
src: k3s.service
dest: /etc/systemd/system/k3s.service
owner: root
group: root
mode: 0644
- name: Enable k3s service
systemd:
name: k3s
daemon_reload: yes
2022-07-21 00:25:58 +00:00
state: started
2021-08-25 04:33:56 +00:00
enabled: yes
- name: Wait for server node-token to be available
wait_for:
path: /var/lib/rancher/k3s/server/node-token
- name: Read node-token from server
slurp:
src: /var/lib/rancher/k3s/server/node-token
register: node_token
- name: Store server node-token as fact
set_fact:
token: "{{ node_token.content | b64decode | regex_replace('\n', '') }}"
- name: Create ~/.kube directory
file:
path: ~/.kube
state: directory
mode: "u=rwx,g=rx,o="
- name: Copy config file to user home directory
copy:
src: /etc/rancher/k3s/k3s.yaml
dest: ~/.kube/config
remote_src: yes
mode: "u=rw,g=,o="
2021-12-28 04:01:35 +00:00
changed_when: no # TODO
2021-08-25 04:33:56 +00:00
- name: Set kubeconfig server ip
command: >-
k3s kubectl config set-cluster default
--server=https://{{ ansible_default_ipv4.address }}:6443
--kubeconfig ~/.kube/config
changed_when: no # TODO
- 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