mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-25 00:12:37 +01:00
Fix k3s_server_location only working on default
- K3s has some absolute paths set in various places which cannot be changed. Using a symbolic link was the easiest fix. This is nice for running K3S on SBC that must boot to SD but K3S data should be stored on a faster drive. - Other changes are for making the site playbook replayable without resetting the cluster. Ideally you can rerun it to check existing nodes or to add new ones. Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
committed by
Derek Nola
parent
7cc70ad609
commit
8484c015d6
@@ -7,7 +7,7 @@
|
||||
systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server
|
||||
--cluster-init --tls-san {{ api_endpoint }} --data-dir {{ k3s_server_location }}
|
||||
{{ extra_server_args}}
|
||||
creates: "{{ systemd_dir }}/k3s-init.service"
|
||||
creates: "{{ k3s_server_location }}/server/node-token"
|
||||
when: groups['server'] | length > 1
|
||||
|
||||
- name: Start temporary service for single server cluster
|
||||
@@ -15,7 +15,7 @@
|
||||
cmd: >
|
||||
systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server
|
||||
--tls-san {{ api_endpoint }} --data-dir {{ k3s_server_location }} {{ extra_server_args }}
|
||||
creates: "{{ systemd_dir }}/k3s-init.service"
|
||||
creates: "{{ k3s_server_location }}/server/node-token"
|
||||
when: groups['server'] | length == 1
|
||||
|
||||
- name: Wait for node-token
|
||||
@@ -75,17 +75,17 @@
|
||||
flat: true
|
||||
when: ansible_hostname == groups['server'][0]
|
||||
|
||||
- name: Init additonal server nodes if any
|
||||
ansible.builtin.command:
|
||||
cmd: >
|
||||
systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server
|
||||
--token "{{ hostvars[groups['server'][0]]['token'] }}" --server https://{{ api_endpoint }}:{{ api_port }}
|
||||
--tls-san {{ api_endpoint }} --data-dir {{ k3s_server_location }} {{ extra_server_args }}
|
||||
creates: "{{ systemd_dir }}/k3s-init.service"
|
||||
when: ansible_hostname != groups['server'][0]
|
||||
|
||||
- name: Verification and cleanup
|
||||
- name: Start other server if any and verify status
|
||||
block:
|
||||
- name: Init additonal server nodes
|
||||
ansible.builtin.command:
|
||||
cmd: >
|
||||
systemd-run -p RestartSec=2 -p Restart=on-failure --unit=k3s-init k3s server
|
||||
--token "{{ hostvars[groups['server'][0]]['token'] }}" --server https://{{ api_endpoint }}:{{ api_port }}
|
||||
--tls-san {{ api_endpoint }} --data-dir {{ k3s_server_location }} {{ extra_server_args }}
|
||||
creates: "{{ k3s_server_location }}/server/node-token"
|
||||
when: ansible_hostname != groups['server'][0]
|
||||
|
||||
- name: Verify that all server nodes joined
|
||||
ansible.builtin.command:
|
||||
cmd: k3s kubectl get nodes -l "node-role.kubernetes.io/control-plane=true" -o=jsonpath="{.items[*].metadata.name}"
|
||||
|
||||
Reference in New Issue
Block a user