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

23 lines
736 B
YAML
Raw Normal View History

2023-01-02 00:41:41 +01:00
---
- 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$'
2023-01-02 00:50:42 +01:00
line: "{{ control_plane_endpoint }} {{ cluster_name }}-cluster-endpoint"
2023-01-02 00:41:41 +01:00
2023-01-02 00:50:42 +01:00
- name: Obtain join command from control_plane
2023-01-02 00:41:41 +01:00
ansible.builtin.command: "kubeadm token create --print-join-command"
2023-01-02 00:50:42 +01:00
when: inventory_hostname != "control_plane"
2023-01-02 00:41:41 +01:00
register: join_cmd
delegate_to: "{{ item }}"
delegate_facts: true
2023-01-02 00:50:42 +01:00
with_items: ["control_plane"]
2023-01-02 00:41:41 +01:00
- name: Execute join command
become: true
ansible.builtin.command: "{{ join_cmd.results[0].stdout }}"