Make kubectl binary configurable with the k3s_kubectl_binary parameter (#567)

Closes techno-tim/k3s-ansible#566

Signed-off-by: Christian Berendt <berendt@osism.tech>
This commit is contained in:
Christian Berendt
2024-08-23 00:58:15 +02:00
committed by GitHub
parent 3a0303d130
commit df8e8dd591
6 changed files with 29 additions and 24 deletions

View File

@@ -1,6 +1,8 @@
---
extra_server_args: ""
k3s_kubectl_binary: k3s kubectl
group_name_master: master
kube_vip_arp: true

View File

@@ -44,7 +44,7 @@
block:
- name: Verify that all nodes actually joined (check k3s-init.service if this fails)
ansible.builtin.command:
cmd: k3s kubectl get nodes -l "node-role.kubernetes.io/master=true" -o=jsonpath="{.items[*].metadata.name}"
cmd: "{{ k3s_kubectl_binary | default('k3s kubectl') }} get nodes -l 'node-role.kubernetes.io/master=true' -o=jsonpath='{.items[*].metadata.name}'" # yamllint disable-line rule:line-length
register: nodes
until: nodes.rc == 0 and (nodes.stdout.split() | length) == (groups[group_name_master | default('master')] | length) # yamllint disable-line rule:line-length
retries: "{{ retry_count | default(20) }}"
@@ -124,7 +124,7 @@
- name: Configure kubectl cluster to {{ endpoint_url }}
ansible.builtin.command: >-
k3s kubectl config set-cluster default
{{ k3s_kubectl_binary | default('k3s kubectl') }} config set-cluster default
--server={{ endpoint_url }}
--kubeconfig {{ ansible_user_dir }}/.kube/config
changed_when: true