Working k3s service and config

This commit is contained in:
Khue Doan 2021-09-01 05:35:35 +07:00
parent 713631587c
commit 8a8d4d7ea2
3 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,6 @@
- name: Restart k3s service
systemd:
name: k3s
daemon_reload: yes
enabled: yes
state: restarted

View File

@ -40,7 +40,6 @@
dest: "{{ k3s_token_file }}"
- name: Copy k3s config files
when: "'masters' in group_names"
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
@ -49,5 +48,6 @@
dest: "{{ k3s_config_file }}"
- src: k3s.service.j2
dest: "{{ k3s_service_file }}"
notify: Restart k3s service
# Get kubeconfig /etc/rancher/k3s/k3s.yaml

View File

@ -1 +1,6 @@
{{ 'server' if 'masters' in group_names else 'agent' }}
{% if inventory_hostname == groups['masters'][0] %}
cluster-init: true
{% else %}
server: https://{{ hostvars[groups['masters'][0]].ansible_host }}:6443
{% endif %}
token-file: {{ k3s_token_file }}