From fd6f288b2074075332615ecfef4aa6c69eeb037d Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Thu, 9 Nov 2023 09:17:20 -0800 Subject: [PATCH] Fix K3s Path, Alternative folder in HA (#233) * Readd #143 fix Signed-off-by: Derek Nola * Add PR template Signed-off-by: Derek Nola --- .github/workflows/pull_request_template.md | 3 +++ Vagrantfile | 1 + roles/k3s/server/tasks/main.yml | 3 ++- roles/prereq/tasks/main.yml | 19 +++++++++++++------ 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/pull_request_template.md diff --git a/.github/workflows/pull_request_template.md b/.github/workflows/pull_request_template.md new file mode 100644 index 0000000..a9a0407 --- /dev/null +++ b/.github/workflows/pull_request_template.md @@ -0,0 +1,3 @@ +#### Changes #### + +#### Linked Issues #### \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index 9c3c96f..dd608f0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -32,6 +32,7 @@ def provision(vm, role, node_num) # Required to use the private network configured above extra_server_args: "--node-external-ip #{node_ip} --flannel-iface eth1", extra_agent_args: "--node-external-ip #{node_ip} --flannel-iface eth1", + k3s_server_location: "/data/k3s", } end end diff --git a/roles/k3s/server/tasks/main.yml b/roles/k3s/server/tasks/main.yml index 63196c2..6bde0af 100644 --- a/roles/k3s/server/tasks/main.yml +++ b/roles/k3s/server/tasks/main.yml @@ -35,6 +35,7 @@ mode: "u=rwx,g=rx,o=" - name: Pause to allow server startup + when: (groups['server'] | length) > 1 ansible.builtin.pause: seconds: 10 @@ -48,7 +49,7 @@ - name: Change server to API endpoint instead of localhost ansible.builtin.command: >- - k3s kubectl config set-cluster default + /usr/local/bin/k3s kubectl config set-cluster default --server=https://{{ api_endpoint }}:{{ api_port }} --kubeconfig ~{{ ansible_user }}/.kube/config changed_when: true diff --git a/roles/prereq/tasks/main.yml b/roles/prereq/tasks/main.yml index be707b0..5db6c1c 100644 --- a/roles/prereq/tasks/main.yml +++ b/roles/prereq/tasks/main.yml @@ -59,12 +59,19 @@ validate: 'visudo -cf %s' when: ansible_distribution in ['CentOS', 'Red Hat Enterprise Linux','RedHat'] -- name: Create symlink - ansible.builtin.file: - dest: /var/lib/rancher/k3s - src: "{{ k3s_server_location }}" - force: true - state: link +- name: Setup alternative K3s directory when: - k3s_server_location is defined - k3s_server_location != "/var/lib/rancher/k3s" + block: + - name: Make rancher directory + ansible.builtin.file: + path: "/var/lib/rancher" + mode: 0755 + state: directory + - name: Create symlink + ansible.builtin.file: + dest: /var/lib/rancher/k3s + src: "{{ k3s_server_location }}" + force: true + state: link