Fix unexpected behaviour when `kubeconfig` is set (#296)
As detailed in https://github.com/k3s-io/k3s-ansible/issues/295, this commit fixes the issue that if `kubeconfig` is set to anything other than the defaults value, then: - `~/.kube/config` is modified. - No file at `{{ kubeconfig }}` is created. - Any existing file and `{{ kubeconfig }}` is deleted. Signed-off-by: Nick To <nick@nickto.net>pull/298/head
parent
fe3df5c836
commit
060362178d
|
@ -119,9 +119,8 @@
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
TFILE=$(mktemp)
|
TFILE=$(mktemp)
|
||||||
KUBECONFIG={{ kubeconfig }} kubectl config set-context k3s-ansible --user=k3s-ansible --cluster=k3s-ansible
|
KUBECONFIG={{ kubeconfig }} kubectl config set-context k3s-ansible --user=k3s-ansible --cluster=k3s-ansible
|
||||||
KUBECONFIG={{ kubeconfig }}:~/.kube/config kubectl config view --flatten > ${TFILE}
|
KUBECONFIG={{ kubeconfig }} kubectl config view --flatten > ${TFILE}
|
||||||
mv ${TFILE} ~/.kube/config
|
mv ${TFILE} {{ kubeconfig }}
|
||||||
rm {{ kubeconfig }}
|
|
||||||
delegate_to: 127.0.0.1
|
delegate_to: 127.0.0.1
|
||||||
become: false
|
become: false
|
||||||
register: mv_result
|
register: mv_result
|
||||||
|
|
Loading…
Reference in New Issue