mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2025-12-25 00:12:37 +01:00
Added custom context name (#315)
* Added custom context name Signed-off-by: Vivek Sarin <vivek@sarin.info> Signed-off-by: Derek Nola <derek.nola@suse.com> Co-authored-by: Vivek Sarin <vivek@sarin.info> Co-authored-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
@@ -120,12 +120,12 @@
|
||||
changed_when:
|
||||
- csa_result.rc == 0
|
||||
|
||||
- name: Setup kubeconfig k3s-ansible context on control node
|
||||
- name: Setup kubeconfig context on control node - {{ cluster_context }}
|
||||
when: kubeconfig != "~/.kube/config"
|
||||
ansible.builtin.replace:
|
||||
path: "{{ kubeconfig }}"
|
||||
regexp: 'name: default'
|
||||
replace: 'name: k3s-ansible'
|
||||
replace: 'name: {{ cluster_context }}'
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
when: kubeconfig != "~/.kube/config"
|
||||
ansible.builtin.shell: |
|
||||
TFILE=$(mktemp)
|
||||
KUBECONFIG={{ kubeconfig }} kubectl config set-context k3s-ansible --user=k3s-ansible --cluster=k3s-ansible
|
||||
KUBECONFIG={{ kubeconfig }} kubectl config set-context {{ cluster_context }} --user={{ cluster_context }} --cluster={{ cluster_context }}
|
||||
KUBECONFIG={{ kubeconfig }} kubectl config view --flatten > ${TFILE}
|
||||
mv ${TFILE} {{ kubeconfig }}
|
||||
delegate_to: 127.0.0.1
|
||||
|
||||
Reference in New Issue
Block a user