sync
This commit is contained in:
34
ansible/playbooks/roles/kubeconfig-manager/tasks/main.yml
Normal file
34
ansible/playbooks/roles/kubeconfig-manager/tasks/main.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
# role: kubeconfig-manager
|
||||
# description: Reusable role for managing kubeconfig files across multiple clusters
|
||||
# author: mk-labs
|
||||
# version: 1.0.0
|
||||
|
||||
- name: Get local user environment
|
||||
delegate_to: localhost
|
||||
ansible.builtin.set_fact:
|
||||
local_home: "{{ lookup('env', 'HOME') }}"
|
||||
local_user: "{{ lookup('env', 'USER') }}"
|
||||
|
||||
- name: Debug local environment
|
||||
delegate_to: localhost
|
||||
ansible.builtin.debug:
|
||||
msg: "Local user: {{ local_user }}, Home directory: {{ local_home }}"
|
||||
|
||||
- name: Create .kube directory
|
||||
delegate_to: localhost
|
||||
ansible.builtin.file:
|
||||
path: "{{ local_home }}/.kube"
|
||||
state: directory
|
||||
owner: "{{ local_user }}"
|
||||
mode: "0755"
|
||||
|
||||
- name: Copy kubeconfig from remote host
|
||||
ansible.builtin.fetch:
|
||||
src: "{{ kubeconfig_source_path | default('/etc/kubernetes/admin.conf') }}"
|
||||
dest: "{{ local_home }}/.kube/config-{{ cluster_name }}"
|
||||
flat: true
|
||||
mode: "0644"
|
||||
|
||||
- name: Include kubeconfig merge tasks
|
||||
ansible.builtin.include_tasks: merge-kubeconfig.yml
|
||||
Reference in New Issue
Block a user