---
- name: Launch instance(s)
  hosts: localhost
  become: no
  connection: local
  gather_facts: no
  vars_files:
  - vars.yml
  vars:
    image_url: "{{ deployment_vars[deployment_type].image.url }}"
    image_sha256: "{{ deployment_vars[deployment_type].image.sha256 }}"
    image_name: "{{ deployment_vars[deployment_type].image.name }}"
    image_compression: "{{ deployment_vars[deployment_type].image.compression }}"
  tasks:
  - include: tasks/configure_libvirt.yml

  - include: ../../common/openshift-cluster/tasks/set_etcd_launch_facts.yml
  - include: tasks/launch_instances.yml
    vars:
      instances: "{{ etcd_names }}"
      cluster: "{{ cluster_id }}"
      type: "{{ k8s_type }}"
      g_sub_host_type: "default"

  - include: ../../common/openshift-cluster/tasks/set_master_launch_facts.yml
  - include: tasks/launch_instances.yml
    vars:
      instances: "{{ master_names }}"
      cluster: "{{ cluster_id }}"
      type: "{{ k8s_type }}"
      g_sub_host_type: "default"

  - include: ../../common/openshift-cluster/tasks/set_node_launch_facts.yml
    vars:
      type: "compute"
      count: "{{ num_nodes }}"
  - include: tasks/launch_instances.yml
    vars:
      instances: "{{ node_names }}"
      cluster: "{{ cluster_id }}"
      type: "{{ k8s_type }}"
      g_sub_host_type: "{{ sub_host_type }}"

  - include: ../../common/openshift-cluster/tasks/set_node_launch_facts.yml
    vars:
      type: "infra"
      count: "{{ num_infra }}"
  - include: tasks/launch_instances.yml
    vars:
      instances: "{{ node_names }}"
      cluster: "{{ cluster_id }}"
      type: "{{ k8s_type }}"
      g_sub_host_type: "{{ sub_host_type }}"

- include: update.yml

- include: list.yml
