· 7 years ago · May 25, 2018, 07:40 PM
1- debug:
2 var: vm_guest_facts.instance.ipv4
3
4- name: Gather facts from recently deployed VM's
5
6 vmware_guest_facts:
7 validate_certs: False
8 hostname: "{{ vcenter_hostname }}"
9 username: "{{ vcenter_user }}"
10 password: "{{ vcenter_pass }}"
11 datacenter: "{{ datacenter }}"
12 name: "{{ item.key }}"
13 register: vm_guest_facts
14 with_dict: "{{ vmdetails }}"
15
16- debug:
17 var: vm_guest_facts
18
19TASK [Gather facts from standalone ESXi server having datacenter as 'ha-
20datacenter']
21
22ok: [terraform.rum.local] => (item={'value': {u'mem': 512, u'network': u'T1-
23PRD', u'datastore': u'nfs-b', u'cpu': 1, u'vmfolder': u'terraform-deploy'},
24'key': u'testvm4'})
25ok: [terraform.rum.local] => (item={'value': {u'mem': 756, u'network': u'T2-
26TEST', u'datastore': u'nfs-a', u'cpu': 2, u'vmfolder': u'terraform-deploy'},
27'key': u'testvm3'})
28
29TASK [debug]
30*************************************
31ok: [terraform.rum.local] => {
32"vm_guest_facts": {
33 "changed": false,
34 "msg": "All items completed",
35 "results": [
36 {
37 "_ansible_ignore_errors": null,
38 "_ansible_item_result": true,
39 "_ansible_no_log": false,
40 "_ansible_parsed": true,
41 "changed": false,
42 "failed": false,
43 "instance": {
44 "annotation": "",
45 "current_snapshot": null,
46 "customvalues": {},
47 "guest_consolidation_needed": false,
48 "guest_question": null,
49 "guest_tools_status": "guestToolsRunning",
50 "guest_tools_version": "10304",
51 "hw_cores_per_socket": 1,
52 "hw_datastores": [
53 "nfs-b",
54 "nfs-a"
55 ],
56 "hw_esxi_host": "esx-a.rum.local",
57 "hw_eth0": {
58 "addresstype": "assigned",
59 "ipaddresses": [
60 "192.168.1.12",
61 "fe80::250:56ff:feb8:d51c"
62 ],
63 "label": "Network adapter 1",
64 "macaddress": "00:50:56:b8:d5:1c",
65 "macaddress_dash": "00-50-56-b8-d5-1c",
66 "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
67 },
68 "hw_files": [
69 "[nfs-b] testvm4/testvm4.vmx",
70 "[nfs-b] testvm4/testvm4.nvram",
71 "[nfs-b] testvm4/testvm4.vmsd",
72 "[nfs-b] testvm4/testvm4.vmxf",
73 "[nfs-b] testvm4/testvm4.vmdk"
74 ],
75 "hw_folder": "/datacenter1/vm/terraform-deploy",
76 "hw_guest_full_name": "CentOS 7 (64-bit)",
77 "hw_guest_ha_state": null,
78 "hw_guest_id": "centos7_64Guest",
79 "hw_interfaces": [
80 "eth0"
81 ],
82 "hw_is_template": false,
83 "hw_memtotal_mb": 512,
84 "hw_name": "testvm4",
85 "hw_power_status": "poweredOn",
86 "hw_processor_count": 1,
87 "hw_product_uuid": "42387ae9-cac5-1faa-1e84-0859533dd2b0",
88 "instance_uuid": "5038a877-e2db-1bfd-6439-78f6522a9049",
89 "ipv4": "192.168.1.12",
90 "ipv6": "fe80::250:56ff:feb8:d51c",
91 "module_hw": true,
92 "snapshots": []
93 },
94 "invocation": {
95 "module_args": {
96 "datacenter": "datacenter1",
97 "folder": "/vm",
98 "hostname": "vcenter.rum.local",
99 "name": "testvm4",
100 "name_match": "first",
101 "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
102 "port": 443,
103 "username": "administrator@vsphere.local",
104 "uuid": null,
105 "validate_certs": false
106 }
107 },
108 "item": {
109 "key": "testvm4",
110 "value": {
111 "cpu": 1,
112 "datastore": "nfs-b",
113 "mem": 512,
114 "network": "T1-PRD",
115 "vmfolder": "terraform-deploy"
116 }
117 }
118 },
119 {
120 "_ansible_ignore_errors": null,
121 "_ansible_item_result": true,
122 "_ansible_no_log": false,
123 "_ansible_parsed": true,
124 "changed": false,
125 "failed": false,
126 "instance": {
127 "annotation": "",
128 "current_snapshot": null,
129 "customvalues": {},
130 "guest_consolidation_needed": false,
131 "guest_question": null,
132 "guest_tools_status": "guestToolsRunning",
133 "guest_tools_version": "10304",
134 "hw_cores_per_socket": 1,
135 "hw_datastores": [
136 "nfs-a"
137 ],
138 "hw_esxi_host": "esx-a.rum.local",
139 "hw_eth0": {
140 "addresstype": "assigned",
141 "ipaddresses": [
142 "192.168.1.16",
143 "fe80::250:56ff:feb8:5e2c"
144 ],
145 "label": "Network adapter 1",
146 "macaddress": "00:50:56:b8:5e:2c",
147 "macaddress_dash": "00-50-56-b8-5e-2c",
148 "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
149 },
150 "hw_files": [
151 "[nfs-a] testvm3/testvm3.vmx",
152 "[nfs-a] testvm3/testvm3.nvram",
153 "[nfs-a] testvm3/testvm3.vmsd",
154 "[nfs-a] testvm3/testvm3.vmxf",
155 "[nfs-a] testvm3/testvm3.vmdk"
156 ],
157 "hw_folder": "/datacenter1/vm/terraform-deploy",
158 "hw_guest_full_name": "CentOS 7 (64-bit)",
159 "hw_guest_ha_state": null,
160 "hw_guest_id": "centos7_64Guest",
161 "hw_interfaces": [
162 "eth0"
163 ],
164 "hw_is_template": false,
165 "hw_memtotal_mb": 756,
166 "hw_name": "testvm3",
167 "hw_power_status": "poweredOn",
168 "hw_processor_count": 2,
169 "hw_product_uuid": "4238b6c3-a81a-cb51-a816-b83627bfcab0",
170 "instance_uuid": "5038a0b1-f75a-f8cb-a872-344afdb1bc6f",
171 "ipv4": "192.168.1.16",
172 "ipv6": "fe80::250:56ff:feb8:5e2c",
173 "module_hw": true,
174 "snapshots": []
175 },
176 "invocation": {
177 "module_args": {
178 "datacenter": "datacenter1",
179 "folder": "/vm",
180 "hostname": "vcenter.rum.local",
181 "name": "testvm3",
182 "name_match": "first",
183 "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
184 "port": 443,
185 "username": "administrator@vsphere.local",
186 "uuid": null,
187 "validate_certs": false
188 }
189 },
190 "item": {
191 "key": "testvm3",
192 "value": {
193 "cpu": 2,
194 "datastore": "nfs-a",
195 "mem": 756,
196 "network": "T2-TEST",
197 "vmfolder": "terraform-deploy"
198 }
199 }
200 }
201 ]
202 }
203}