---
- name: Install, configure Kubernetes cluster, and join nodes
  hosts: all
  become: yes
  gather_facts: no
  vars:
    kubernetes_version: 'v1.29'
    project_path: 'prerelease:/main'
  vars_files:
    - secrets.yaml
  tasks:
    - name: Set is_control_plane fact
      set_fact:
        is_control_plane: "{{ 'true' if inventory_hostname == groups['control_plane'][0] else 'false' }}"

    - name: Include Setup Hosts Tasks
      import_tasks: tasks/setup_hosts.yml
      tags: [setup_hosts]

    - name: Include Bootstrap Cluster Tasks
      import_tasks: tasks/bootstrap_cluster.yml
      tags: [bootstrap]

  handlers:
    - name: Apply sysctl settings
      ansible.builtin.sysctl:
        sysctl_set: yes
        state: present
        reload: yes
        name: net.ipv4.ip_forward
        value: '1'
