Hi All,
Trying to Output only the Virtual Machine Name: but having issues with the
Json output
---
- name: Running Create Virtual Machine Playbook
hosts: localhost
gather_facts: false
connection: local
tasks:
- name: Get VMs
vmware_vm_info:
validate_certs: no
hostname:
username:
password:
vm_type: vm
delegate_to: localhost
register: vminfo
- debug:
var: vminfo.virtual_machines.guest_name
- local_action: copy content={{ vminfo.virtual_machines.guest_name }}
dest=/srv/ansible/vmname.json
I'm currently getting the following Error:
TASK [debug]
*****************************************************************************************************************************************
ok: [localhost] => {
"vminfo.virtual_machines.guest_name": "VARIABLE IS NOT DEFINED!"
}
This is the JSON output if i just do a var vminfo
{
"failed": false,
"virtual_machines":
[
{
"guest_name": "",
"guest_fullname": "CentOS 7 (64-bit)",
"esxi_hostname": "e",
"tags": [],
"cluster": "",
"vm_network":
{
"":
{
"ipv4": [""],
"ipv6": []
},
"":
{"ipv4": [""],
"ipv6": []},
"": {"ipv4": [""], "ipv6": ["f"]}}, "mac_address": [""],
"attributes": {}, "power_state": "poweredOn", "ip_address": "", "uuid":
"4212ca75-8a0a-e9dc-95bc-3ee10ea6af11"
},
{
"guest_name": "", "guest_fullname": "Microsoft Windows 8 (64-bit)",
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/218fea74-3de0-468f-a9d7-8ab73f826a6a%40googlegroups.com.