forked from GoogleCloudPlatform/compute-video-demo-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gce-instances.yml
44 lines (44 loc) · 1.64 KB
/
gce-instances.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
# compute-video-demo-ansible
- name: Create Compute Engine instances
hosts: local
gather_facts: False
vars_files:
- gce_vars/auth
- gce_vars/machines
- gce_vars/zonea
- gce_vars/zoneb
tasks:
- name: Bring up the instances in the first zone
gce:
instance_names: "{{ names_zonea }}"
machine_type: "{{ machine_type }}"
image: "{{ image }}"
zone: "{{ zonea }}"
project_id: "{{ project_id }}"
credentials_file: "{{ credentials_file }}"
service_account_email: "{{ service_account_email }}"
register: gcea
- name: Bring up the instances in the second zone
gce:
instance_names: "{{ names_zoneb }}"
machine_type: "{{ machine_type }}"
image: "{{ image }}"
zone: "{{ zoneb }}"
project_id: "{{ project_id }}"
credentials_file: "{{ credentials_file }}"
service_account_email: "{{ service_account_email }}"
register: gceb
post_tasks:
- name: Wait for SSH for instances in first zone
wait_for: delay=1 host={{ item.public_ip }} port=22 state=started timeout=30
with_items: "{{ gcea.instance_data }}"
- name: Save host data for first zone
add_host: hostname={{ item.public_ip }} groupname=gce_instances_ips
with_items: "{{ gcea.instance_data }}"
- name: Wait for SSH for instances in second zone
wait_for: delay=1 host={{ item.public_ip }} port=22 state=started timeout=30
with_items: "{{ gceb.instance_data }}"
- name: Save host data for second zone
add_host: hostname={{ item.public_ip }} groupname=gce_instances_ips
with_items: "{{ gceb.instance_data }}"