---
- name: Check ansible version
  import_playbook: ansible_version.yml

- name: Add kube-master nodes to kube_control_plane
  # This is for old inventory which contains kube-master instead of kube_control_plane
  hosts: kube-master
  gather_facts: false
  tasks:
    - name: add nodes to kube_control_plane group
      group_by:
        key: 'kube_control_plane'

- hosts: bastion[0]
  gather_facts: False
  environment: "{{ proxy_disable_env }}"
  roles:
    - { role: kubespray-defaults}
    - { role: bastion-ssh-config, tags: ["localhost", "bastion"]}

- hosts: "{{ groups['etcd'] | first }}"
  environment: "{{ proxy_disable_env }}"
  roles:
    - { role: kubespray-defaults}
    - { role: recover_control_plane/etcd }

- hosts: "{{ groups['kube_control_plane'] | first }}"
  environment: "{{ proxy_disable_env }}"
  roles:
    - { role: kubespray-defaults}
    - { role: recover_control_plane/control-plane }

- include: cluster.yml

- hosts: "{{ groups['kube_control_plane'] }}"
  environment: "{{ proxy_disable_env }}"
  roles:
    - { role: kubespray-defaults}
    - { role: recover_control_plane/post-recover }
