Skip to content

Commit

Permalink
add: validation before joining to cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
pasiol committed Dec 26, 2024
1 parent 593260d commit 108dee4
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions roles/cluster_workers_join/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
---
# TODO: check is worker already joined

- name: Get join command
become: true
delegate_to: "{{ cluster_workers_join_first_control_plane.ipv4 | split('/') | first }}"
- name: Get cluster nodes
delegate_to: kvm_host_local
connection: local
changed_when: true
register: result
register: cluster_workers_join_result
ansible.builtin.command:
cmd: >
kubeadm token create --print-join-command
cmd: kubectl get nodes

- name: Set fact join command
register: result
until: result is not failed
retries: 25
delay: 10
ansible.builtin.set_fact:
cluster_workers_join_command: /usr/bin/{{ result.stdout }}
- name: Join to cluster
when: inventory_hostname not in cluster_workers_join_result.stdout
block:

- name: Join to the cluster
become: true
changed_when: true
register: result
until: result is not failed
retries: 25
delay: 10
ansible.builtin.command:
cmd: >
{{ cluster_workers_join_command }}
- name: Get join command
become: true
delegate_to: "{{ cluster_workers_join_first_control_plane.ipv4 | split('/') | first }}"
changed_when: true
register: result
ansible.builtin.command:
cmd: >
kubeadm token create --print-join-command
- name: Set fact join command
register: result
until: result is not failed
retries: 25
delay: 10
ansible.builtin.set_fact:
cluster_workers_join_command: /usr/bin/{{ result.stdout }}

- name: Join to the cluster
become: true
changed_when: true
register: result
until: result is not failed
retries: 25
delay: 10
ansible.builtin.command:
cmd: >
{{ cluster_workers_join_command }}

0 comments on commit 108dee4

Please sign in to comment.