70 lines
1.6 KiB
YAML
70 lines
1.6 KiB
YAML
|
- 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
|
||
|
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="
|
||
|
|
||
|
- 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
|
||
|
|
||
|
# - name: Create longhorn install directory
|
||
|
# file:
|
||
|
# path: /var/lib/rancher/k3s/server/manifests/longhorn
|
||
|
# state: directory
|
||
|
|
||
|
# - name: Install longhorn
|
||
|
# get_url:
|
||
|
# url: https://raw.githubusercontent.com/longhorn/longhorn/v1.2.0/deploy/longhorn.yaml
|
||
|
# dest: /var/lib/rancher/k3s/server/manifests/longhorn/longhorn.yaml
|