Skip to content

Commit

Permalink
fetch kubeconfig from master after deployment (techno-tim#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Techno Tim <[email protected]>
  • Loading branch information
gereonvey and timothystewart6 authored Jan 27, 2024
1 parent 3888a29 commit 3f06a11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env/
*.log
ansible.cfg
kubeconfig
11 changes: 11 additions & 0 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

0 comments on commit 3f06a11

Please sign in to comment.