22 lines
736 B
YAML
22 lines
736 B
YAML
---
|
|
- name: Join the cluster
|
|
block:
|
|
- name: Set cluster endpoint record
|
|
become: true
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/hosts
|
|
state: present
|
|
regexp: '^\d+\.\d+\.\d+\.\d+\ .*-cluster-endpoint$'
|
|
line: "{{ control_plane_endpoint }} {{ cluster_name }}-cluster-endpoint"
|
|
|
|
- name: Obtain join command from control_plane
|
|
ansible.builtin.command: "kubeadm token create --print-join-command"
|
|
when: inventory_hostname != "control_plane"
|
|
register: join_cmd
|
|
delegate_to: "{{ item }}"
|
|
delegate_facts: true
|
|
with_items: ["control_plane"]
|
|
|
|
- name: Execute join command
|
|
become: true
|
|
ansible.builtin.command: "{{ join_cmd.results[0].stdout }}"
|