Skip to content

Commit

Permalink
do not blindly overwrite kube config (#263)
Browse files Browse the repository at this point in the history
* do not blindly overwrite kube config

Signed-off-by: Roman Ivanov <[email protected]>

* don't need to check if an existing config exists

Co-authored-by: Derek Nola <[email protected]>
Signed-off-by: Roman Ivanov <[email protected]>
  • Loading branch information
roivanov and dereknola authored Dec 1, 2023
1 parent 34bf054 commit ec02f1c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,21 @@
- name: Copy kubectl config to local machine
ansible.builtin.fetch:
src: ~{{ ansible_user }}/.kube/config
dest: ~/.kube/config
dest: ~/.kube/config.new
flat: true

- name: Merge with any existing kube config
ansible.builtin.shell: |
TFILE=$(mktemp)
KUBECONFIG=~/.kube/config:~/.kube/config.new kubectl config view --flatten > ${TFILE}
mv ${TFILE} ~/.kube/config
rm ~/.kube/config.new
delegate_to: 127.0.0.1
become: false
register: mv_result
changed_when:
- mv_result.rc == 0

- name: Start other server if any and verify status
when:
- (groups['server'] | length) > 1
Expand Down

0 comments on commit ec02f1c

Please sign in to comment.