ansible/roles/kubernetes/node/tasks/main.yml

23 lines
726 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: "{{ controlplane_ip }} {{ cluster_name }}-cluster-endpoint"
- name: Obtain join command from controlplane
ansible.builtin.command: "kubeadm token create --print-join-command"
when: inventory_hostname != "controlplane"
register: join_cmd
delegate_to: "{{ item }}"
delegate_facts: true
with_items: ["controlplane"]
- name: Execute join command
become: true
ansible.builtin.command: "{{ join_cmd.results[0].stdout }}"