-
Notifications
You must be signed in to change notification settings - Fork 5
/
grab-vm-info.yml
30 lines (27 loc) · 1.34 KB
/
grab-vm-info.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
---
- name: Grab some specific details about the GCP VM instances and display them
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Retrieve info for the GCP VM instances
google.cloud.gcp_compute_instance_info:
zone: "{{ gcp_zone }}"
project: "{{ gcp_project }}"
auth_kind: serviceaccount
register: gcp_instance_info
- name: Display GCP VM Detailed information to terminal
ansible.builtin.debug:
msg:
- "Display the GCP VM information that we desire for {{ item.name }}"
- "VM Instance Name: {{ item.name | default('The tag *Name* Does not exist') }}"
- "VM Instance ID: {{ item.id }}"
- "VM Labels: {{ item.labels | default('NO *Labels* exist') }}"
- "VM Instance State: {{ item.status }}"
- "VM Machine Type: {{ item.machineType }}"
- "VM Private IP: {{ item.networkInterfaces[0].networkIP | default('NO *Private IP* exist') }}"
- "VM Public IP: {{ item.networkInterfaces[0].accessConfigs[0].natIP | default('NO *Public IP* exist') }}"
loop: "{{ gcp_instance_info.resources }}"
# when: item.status == "RUNNING"
loop_control:
label: "Display the VM information that we desire"