forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcp_instances_start.yml
36 lines (33 loc) · 1.25 KB
/
gcp_instances_start.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
---
- name: Find Bastion
environment:
PATH: '{{ output_dir }}/google-cloud-sdk/bin:/usr/bin:/usr/local/bin'
CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: "{{ gcp_credentials_file }}"
CLOUDSDK_COMPUTE_REGION: "{{ gcp_region }}"
CLOUDSDK_CONFIG: "{{ output_dir }}/.gcloud-{{ guid }}"
CLOUDSDK_CORE_PROJECT: "{{ gcp_project_id }}"
command: "gcloud compute instances list --filter=\"name~'^{{ project_tag }}-vm$'\" --format json"
register: r_vm_info
- name: Get Zone
set_fact:
gcp_zone: "{{ r_vm_info.stdout | from_json | first | json_query('zone') | regex_replace('^.*zones\/', '') }}"
- name: Start Bastion
google.cloud.gcp_compute_instance:
auth_kind: "{{ gcp_auth_type }}"
service_account_file: "{{ gcp_credentials_file }}"
name: "{{ project_tag }}-vm"
project: "{{ gcp_project_id }}"
zone: "{{ gcp_zone }}"
status: RUNNING
- name: Wait until bastion is running
google.cloud.gcp_compute_instance_info:
auth_kind: "{{ gcp_auth_type }}"
service_account_file: "{{ gcp_credentials_file }}"
filters:
- name = "{{ project_tag }}-vm"
project: "{{ gcp_project_id }}"
zone: "{{ gcp_zone }}"
register: r_instance_status
until: r_instance_status.resources[0].status == "RUNNING"
delay: 10
retries: 60