-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: validation before joining to cluster
- Loading branch information
Showing
1 changed file
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |