fetch kubeconfig from master after deployment (#431)

Co-authored-by: Techno Tim <timothystewart6@gmail.com>
This commit is contained in:
Gereon Vey 2024-01-27 23:30:13 +01:00 committed by GitHub
parent 3888a29bb1
commit 3f06a11c8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env/
*.log
ansible.cfg
kubeconfig

View File

@ -46,3 +46,14 @@
roles:
- role: k3s_server_post
become: true
- name: Storing kubeconfig in the playbook directory
hosts: master
environment: "{{ proxy_env | default({}) }}"
tasks:
- name: Copying kubeconfig from {{ hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname'] }}
ansible.builtin.fetch:
src: "{{ ansible_user_dir }}/.kube/config"
dest: ./kubeconfig
flat: true
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']