---
- name: Launch instance(s)
  hosts: localhost
  connection: local
  gather_facts: no
  vars_files:
  - vars.yml
  tasks:
  - fail: msg="Deployment type not supported for gce provider yet"
    when: deployment_type == 'enterprise'

  - include: ../../common/openshift-cluster/set_master_launch_facts_tasks.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/set_node_launch_facts_tasks.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/set_node_launch_facts_tasks.yml
    vars:
      type: "infra"
      count: "{{ num_infra }}"
  - include: tasks/launch_instances.yml
    vars:
      instances: "{{ infra_names }}"
      cluster: "{{ cluster_id }}"
      type: "{{ k8s_type }}"
      g_sub_host_type: "{{ sub_host_type }}"

  - set_fact:
      a_infra: "{{ infra_names[0] }}"
  - add_host: name={{ a_infra }} groups=service_master

- include: update.yml

- name: Deploy OpenShift Services
  hosts: service_master
  connection: ssh
  gather_facts: yes
  roles:
  - openshift_registry
  - openshift_router

- include: ../../common/openshift-cluster/create_services.yml
  vars:
     g_svc_master: "{{ service_master }}"

- include: list.yml