Skip to content

Commit

Permalink
Add manager/copy-kubeconfig play (#388)
Browse files Browse the repository at this point in the history
This play copies the kubeconfig to the configuraton repository.

Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored Mar 11, 2024
1 parent acd3778 commit ccd30b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions playbooks/manager-copy-kubeconfig.yml
30 changes: 30 additions & 0 deletions playbooks/manager/copy-kubeconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- name: Copy kubeconfig to the configuration repository
hosts: manager
gather_facts: false

vars:
configuration_directory: /opt/configuration

tasks:
- name: Get kubeconfig file
become: true
ansible.builtin.slurp:
src: /etc/rancher/k3s/k3s.yaml
delegate_to: "{{ groups[hosts_k3s_master | default('k3s_master')][0] }}"
register: kubeconfig

- name: Write kubeconfig file
ansible.builtin.copy:
content: "{{ kubeconfig['content'] | b64decode }}"
dest: "{{ configuration_directory }}/environments/kolla/files/overlays/magnum/kubeconfig"
mode: 0640
owner: dragon
group: dragon

- name: Change server address in the kubeconfig file
ansible.builtin.lineinfile:
path: "{{ configuration_directory }}/environments/kolla/files/overlays/magnum/kubeconfig"
regexp: "^(.*server: https://)127.0.0.1(:6443)"
line: \g<1>{{ apiserver_endpoint }}\g<2>
backrefs: yes

0 comments on commit ccd30b7

Please sign in to comment.