From ca67c6865a1cefd1d9fba6aa280dc2f6638e5850 Mon Sep 17 00:00:00 2001 From: alankan-finocomp <79436574+alankan-finocomp@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:51:59 +1000 Subject: [PATCH] Fix kubeconfig merge with existing config Signed-off-by: alankan-finocomp <79436574+alankan-finocomp@users.noreply.github.com> --- roles/k3s_server/tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/k3s_server/tasks/main.yml b/roles/k3s_server/tasks/main.yml index 538ea29a5..0acfddaf5 100644 --- a/roles/k3s_server/tasks/main.yml +++ b/roles/k3s_server/tasks/main.yml @@ -151,8 +151,8 @@ when: kubeconfig != "~/.kube/config" ansible.builtin.replace: path: "{{ kubeconfig }}" - regexp: 'name: default' - replace: 'name: {{ cluster_context }}' + regexp: 'default' + replace: '{{ cluster_context }}' delegate_to: 127.0.0.1 become: false @@ -160,8 +160,8 @@ when: kubeconfig != "~/.kube/config" ansible.builtin.shell: | TFILE=$(mktemp) - KUBECONFIG={{ kubeconfig }} kubectl config set-context {{ cluster_context }} --user={{ cluster_context }} --cluster={{ cluster_context }} - KUBECONFIG={{ kubeconfig }} kubectl config view --flatten > ${TFILE} + KUBECONFIG={{ kubeconfig }}:~/.kube/config kubectl config set-context {{ cluster_context }} --user={{ cluster_context }} --cluster={{ cluster_context }} + KUBECONFIG={{ kubeconfig }}:~/.kube/config kubectl config view --flatten > ${TFILE} mv ${TFILE} {{ kubeconfig }} delegate_to: 127.0.0.1 become: false