skip error when fetching kubeconfig

This commit is contained in:
srwadleigh 2024-06-07 17:18:20 +00:00
parent 3b99f443e4
commit 98436c12c1
3 changed files with 3 additions and 4 deletions

View File

@ -36,9 +36,6 @@ k8s_taint_servers: false
# apply label role=agent to agent nodes
k8s_label_agents: false
# fetch kubeconfig from the bootstrap node
# k8s_get_kubeconf: always | never
# shared k8s api port
k8s_api_port: 6443

View File

@ -112,7 +112,7 @@
- k8s_node_type == "bootstrap"
tags:
- k8s-get-kubeconf
- "{{ k8s_get_kubeconf | d('always') }}"
- name: include secret block
ansible.builtin.include_tasks: "shared/secrets.yml"
when:

View File

@ -7,6 +7,7 @@
block:
- name: fetch kubeconfig
ignore_errors: yes
ansible.builtin.fetch:
src: "{{ k8s_config_path }}/{{ k8s_type }}.yaml"
dest: "$HOME/.kube/config-{{ k8s_cluster_name }}.yaml"
@ -16,6 +17,7 @@
delegate_to: localhost
connection: local
become: false
ignore_errors: yes
ansible.builtin.shell: |
yq e '.clusters[].name = "{{ k8s_cluster_name }}"' -i $HOME/.kube/config-{{ k8s_cluster_name }}.yaml
yq e '.contexts[].name = "{{ k8s_cluster_context | d(k8s_cluster_name) }}"' -i $HOME/.kube/config-{{ k8s_cluster_name }}.yaml