do not blindly overwrite kube config (#263)

* do not blindly overwrite kube config

Signed-off-by: Roman Ivanov <me@roivanov.com>

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

Co-authored-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Roman Ivanov <me@roivanov.com>
This commit is contained in:
Roman Ivanov 2023-12-01 09:00:30 -08:00 committed by GitHub
parent 34bf054f94
commit ec02f1cafd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -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