---

- name: 'apply kubernetes setup to {{ host | default("all") }}'
  hosts: '{{ host | default("kube_control_plane") }}'
  serial: "{{ serial_number | default(10) }}"

  pre_tasks:
    - name: "Check if ansible version is at least 2.10.x"
      assert:
        that:
          - ansible_version.major >= 2
          - ansible_version.minor >= 10
        msg: "The ansible version has to be at least ({{ ansible_version.full }})"
      tags:
        - always

    - name: "Import autodiscover pre-tasks"
      import_tasks: tasks/autodiscover_pre_tasks.yml
      tags:
        - always

  roles:
    - { role: kubernetes/base }
    - { role: kubernetes/namespace }
    - { role: kubernetes/cloud_controller_manager }
    - { role: kubernetes/container_storage_interface }
    - { role: kubernetes/prometheus }
    - { role: kubernetes/cert_manager }
    - { role: kubernetes/external_dns }
    - { role: kubernetes/ingress_controller }
    - role: kubernetes/argocd
      when: kubernetes_with_argocd | default(True)
    - role: kubernetes/awx
      when: kubernetes_with_awx | default(True)
