From 6e29200d9aaf111b96bfdb1612639ad72fe5e1c9 Mon Sep 17 00:00:00 2001 From: Xan Manning Date: Mon, 19 Oct 2020 20:32:53 +0100 Subject: [PATCH] Attempt to fix #57 - k3s_node_data_dir set in templates --- tasks/build/configure-k3s-cluster.yml | 2 +- templates/k3s-killall.sh.j2 | 4 ++-- templates/k3s-uninstall.sh.j2 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/build/configure-k3s-cluster.yml b/tasks/build/configure-k3s-cluster.yml index dfa0019..efab428 100644 --- a/tasks/build/configure-k3s-cluster.yml +++ b/tasks/build/configure-k3s-cluster.yml @@ -2,7 +2,7 @@ - name: Ensure NODE_TOKEN is captured from control node slurp: - path: "/var/lib/rancher/k3s/server/node-token" + path: "{{ k3s_node_data_dir | default ('/var/lib/rancher/k3s') }}/server/node-token" register: k3s_slurped_control_token delegate_to: "{{ k3s_control_delegate }}" when: k3s_control_token is not defined and not ansible_check_mode diff --git a/templates/k3s-killall.sh.j2 b/templates/k3s-killall.sh.j2 index 534eb8e..0a1f0e2 100644 --- a/templates/k3s-killall.sh.j2 +++ b/templates/k3s-killall.sh.j2 @@ -2,7 +2,7 @@ [ $(id -u) -eq 0 ] || exec sudo $0 $@ -for bin in /var/lib/rancher/k3s/data/**/bin/; do +for bin in {{ k3s_node_data_dir | default('/var/lib/rancher/k3s') }}/data/**/bin/; do [ -d "$bin" ] && export PATH=$bin:$PATH done @@ -62,7 +62,7 @@ do_unmount() { } do_unmount '/run/k3s' -do_unmount '/var/lib/rancher/k3s' +do_unmount '{{ k3s_node_data_dir | default('/var/lib/rancher/k3s') }}' do_unmount '/var/lib/kubelet/pods' do_unmount '/run/netns/cni-' diff --git a/templates/k3s-uninstall.sh.j2 b/templates/k3s-uninstall.sh.j2 index 71a66f9..b660ec1 100644 --- a/templates/k3s-uninstall.sh.j2 +++ b/templates/k3s-uninstall.sh.j2 @@ -55,7 +55,7 @@ for bin in {{ k3s_install_dir }}/k3s*; do done [ -d /etc/rancher/k3s ] && rm -rf /etc/rancher/k3s -[ -d /var/lib/rancher/k3s ] && rm -rf /var/lib/rancher/k3s +[ -d {{ k3s_node_data_dir | default('/var/lib/rancher/k3s') }} ] && rm -rf {{ k3s_node_data_dir | default('/var/lib/rancher/k3s') }} [ -d /var/lib/kubelet ] && rm -rf /var/lib/kubelet [ -f /usr/local/bin/k3s-killall.sh ] && rm -f /usr/local/bin/k3s-killall.sh