Ansible vmware_guest_facts use facts for multple vm'sAnsible Gathering Facts not working?How to see stdout of ansible commands?How to get remote server facts on ansibleAnsible stuck on gathering factsAnsible sudo actions on Azure VM'sansible custom facts returning string not arrayansible: gather facts in a task?Ansible = use facts as variables in inventory fileAnsible Loop Over Custom FactsPrint Ansible facts from a loop

Why is the relationship between frequency and pitch exponential?

Select items in a list that contain criteria

2.8 is missing the Carve option in the Boolean Modifier

How bad would a partial hash leak be, realistically?

What do we gain with higher order logics?

Version 2 - print new even-length arrays from two arrays

Can a user sell my software (MIT license) without modification?

Does an ice chest packed full of frozen food need ice?

After the loss of Challenger, why weren’t Galileo and Ulysses launched by Centaurs on expendable boosters?

Why heater blocks on hotends?

How to retract the pitched idea from employer?

Smooth switching between 12v batteries, with toggle switch

Traffic law UK, pedestrians

Why does Kathryn say this in 12 Monkeys?

Do any instruments not produce overtones?

Last survivors from different time periods living together

How is it possible that Gollum speaks Westron?

Why only the fundamental frequency component is said to give useful power?

Why don’t airliners have temporary liveries?

What are the peak hours for public transportation in Paris?

Payment instructions from HomeAway look fishy to me

Where does this pattern of naming products come from?

Company did not petition for visa in a timely manner. Is asking me to work from overseas, but wants me to take a paycut

Implement Homestuck's Catenative Doomsday Dice Cascader



Ansible vmware_guest_facts use facts for multple vm's


Ansible Gathering Facts not working?How to see stdout of ansible commands?How to get remote server facts on ansibleAnsible stuck on gathering factsAnsible sudo actions on Azure VM'sansible custom facts returning string not arrayansible: gather facts in a task?Ansible = use facts as variables in inventory fileAnsible Loop Over Custom FactsPrint Ansible facts from a loop






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am writing a script where I deploy and configure VM's on a vSphere environment.



After the deployment I want to gather the IP's of the VM's for DNS registration.
Facts can be gathered for 2 or more VM's at the same time.
But how do I then use the gathered data to output a VM name with IP address?



For a single VM this works to get the IP, but when used with 2 VM's the variable is undefinied:



- debug:
var: vm_guest_facts.instance.ipv4


Maybe my approach is wrong, but I am not really sure how else to do it.



- name: Gather facts from recently deployed VM's

vmware_guest_facts:
validate_certs: False
hostname: " vcenter_hostname "
username: " vcenter_user "
password: " vcenter_pass "
datacenter: " datacenter "
name: " item.key "
register: vm_guest_facts
with_dict: " vmdetails "

- debug:
var: vm_guest_facts


Results (the hostname and folder is Terraform, but this example only uses Ansible):



TASK [Gather facts from standalone ESXi server having datacenter as 'ha- 
datacenter']

ok: [terraform.rum.local] => (item='value': u'mem': 512, u'network': u'T1-
PRD', u'datastore': u'nfs-b', u'cpu': 1, u'vmfolder': u'terraform-deploy',
'key': u'testvm4')
ok: [terraform.rum.local] => (item='value': u'mem': 756, u'network': u'T2-
TEST', u'datastore': u'nfs-a', u'cpu': 2, u'vmfolder': u'terraform-deploy',
'key': u'testvm3')

TASK [debug]
*************************************
ok: [terraform.rum.local] =>
"vm_guest_facts":
"changed": false,
"msg": "All items completed",
"results": [

"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"failed": false,
"instance":
"annotation": "",
"current_snapshot": null,
"customvalues": ,
"guest_consolidation_needed": false,
"guest_question": null,
"guest_tools_status": "guestToolsRunning",
"guest_tools_version": "10304",
"hw_cores_per_socket": 1,
"hw_datastores": [
"nfs-b",
"nfs-a"
],
"hw_esxi_host": "esx-a.rum.local",
"hw_eth0":
"addresstype": "assigned",
"ipaddresses": [
"192.168.1.12",
"fe80::250:56ff:feb8:d51c"
],
"label": "Network adapter 1",
"macaddress": "00:50:56:b8:d5:1c",
"macaddress_dash": "00-50-56-b8-d5-1c",
"summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
,
"hw_files": [
"[nfs-b] testvm4/testvm4.vmx",
"[nfs-b] testvm4/testvm4.nvram",
"[nfs-b] testvm4/testvm4.vmsd",
"[nfs-b] testvm4/testvm4.vmxf",
"[nfs-b] testvm4/testvm4.vmdk"
],
"hw_folder": "/datacenter1/vm/terraform-deploy",
"hw_guest_full_name": "CentOS 7 (64-bit)",
"hw_guest_ha_state": null,
"hw_guest_id": "centos7_64Guest",
"hw_interfaces": [
"eth0"
],
"hw_is_template": false,
"hw_memtotal_mb": 512,
"hw_name": "testvm4",
"hw_power_status": "poweredOn",
"hw_processor_count": 1,
"hw_product_uuid": "42387ae9-cac5-1faa-1e84-0859533dd2b0",
"instance_uuid": "5038a877-e2db-1bfd-6439-78f6522a9049",
"ipv4": "192.168.1.12",
"ipv6": "fe80::250:56ff:feb8:d51c",
"module_hw": true,
"snapshots": []
,
"invocation":
"module_args":
"datacenter": "datacenter1",
"folder": "/vm",
"hostname": "vcenter.rum.local",
"name": "testvm4",
"name_match": "first",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"username": "administrator@vsphere.local",
"uuid": null,
"validate_certs": false

,
"item":
"key": "testvm4",
"value":
"cpu": 1,
"datastore": "nfs-b",
"mem": 512,
"network": "T1-PRD",
"vmfolder": "terraform-deploy"


,

"_ansible_ignore_errors": null,
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"failed": false,
"instance":
"annotation": "",
"current_snapshot": null,
"customvalues": ,
"guest_consolidation_needed": false,
"guest_question": null,
"guest_tools_status": "guestToolsRunning",
"guest_tools_version": "10304",
"hw_cores_per_socket": 1,
"hw_datastores": [
"nfs-a"
],
"hw_esxi_host": "esx-a.rum.local",
"hw_eth0":
"addresstype": "assigned",
"ipaddresses": [
"192.168.1.16",
"fe80::250:56ff:feb8:5e2c"
],
"label": "Network adapter 1",
"macaddress": "00:50:56:b8:5e:2c",
"macaddress_dash": "00-50-56-b8-5e-2c",
"summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
,
"hw_files": [
"[nfs-a] testvm3/testvm3.vmx",
"[nfs-a] testvm3/testvm3.nvram",
"[nfs-a] testvm3/testvm3.vmsd",
"[nfs-a] testvm3/testvm3.vmxf",
"[nfs-a] testvm3/testvm3.vmdk"
],
"hw_folder": "/datacenter1/vm/terraform-deploy",
"hw_guest_full_name": "CentOS 7 (64-bit)",
"hw_guest_ha_state": null,
"hw_guest_id": "centos7_64Guest",
"hw_interfaces": [
"eth0"
],
"hw_is_template": false,
"hw_memtotal_mb": 756,
"hw_name": "testvm3",
"hw_power_status": "poweredOn",
"hw_processor_count": 2,
"hw_product_uuid": "4238b6c3-a81a-cb51-a816-b83627bfcab0",
"instance_uuid": "5038a0b1-f75a-f8cb-a872-344afdb1bc6f",
"ipv4": "192.168.1.16",
"ipv6": "fe80::250:56ff:feb8:5e2c",
"module_hw": true,
"snapshots": []
,
"invocation":
"module_args":
"datacenter": "datacenter1",
"folder": "/vm",
"hostname": "vcenter.rum.local",
"name": "testvm3",
"name_match": "first",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"username": "administrator@vsphere.local",
"uuid": null,
"validate_certs": false

,
"item":
"key": "testvm3",
"value":
"cpu": 2,
"datastore": "nfs-a",
"mem": 756,
"network": "T2-TEST",
"vmfolder": "terraform-deploy"



]











share|improve this question




























    1















    I am writing a script where I deploy and configure VM's on a vSphere environment.



    After the deployment I want to gather the IP's of the VM's for DNS registration.
    Facts can be gathered for 2 or more VM's at the same time.
    But how do I then use the gathered data to output a VM name with IP address?



    For a single VM this works to get the IP, but when used with 2 VM's the variable is undefinied:



    - debug:
    var: vm_guest_facts.instance.ipv4


    Maybe my approach is wrong, but I am not really sure how else to do it.



    - name: Gather facts from recently deployed VM's

    vmware_guest_facts:
    validate_certs: False
    hostname: " vcenter_hostname "
    username: " vcenter_user "
    password: " vcenter_pass "
    datacenter: " datacenter "
    name: " item.key "
    register: vm_guest_facts
    with_dict: " vmdetails "

    - debug:
    var: vm_guest_facts


    Results (the hostname and folder is Terraform, but this example only uses Ansible):



    TASK [Gather facts from standalone ESXi server having datacenter as 'ha- 
    datacenter']

    ok: [terraform.rum.local] => (item='value': u'mem': 512, u'network': u'T1-
    PRD', u'datastore': u'nfs-b', u'cpu': 1, u'vmfolder': u'terraform-deploy',
    'key': u'testvm4')
    ok: [terraform.rum.local] => (item='value': u'mem': 756, u'network': u'T2-
    TEST', u'datastore': u'nfs-a', u'cpu': 2, u'vmfolder': u'terraform-deploy',
    'key': u'testvm3')

    TASK [debug]
    *************************************
    ok: [terraform.rum.local] =>
    "vm_guest_facts":
    "changed": false,
    "msg": "All items completed",
    "results": [

    "_ansible_ignore_errors": null,
    "_ansible_item_result": true,
    "_ansible_no_log": false,
    "_ansible_parsed": true,
    "changed": false,
    "failed": false,
    "instance":
    "annotation": "",
    "current_snapshot": null,
    "customvalues": ,
    "guest_consolidation_needed": false,
    "guest_question": null,
    "guest_tools_status": "guestToolsRunning",
    "guest_tools_version": "10304",
    "hw_cores_per_socket": 1,
    "hw_datastores": [
    "nfs-b",
    "nfs-a"
    ],
    "hw_esxi_host": "esx-a.rum.local",
    "hw_eth0":
    "addresstype": "assigned",
    "ipaddresses": [
    "192.168.1.12",
    "fe80::250:56ff:feb8:d51c"
    ],
    "label": "Network adapter 1",
    "macaddress": "00:50:56:b8:d5:1c",
    "macaddress_dash": "00-50-56-b8-d5-1c",
    "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
    ,
    "hw_files": [
    "[nfs-b] testvm4/testvm4.vmx",
    "[nfs-b] testvm4/testvm4.nvram",
    "[nfs-b] testvm4/testvm4.vmsd",
    "[nfs-b] testvm4/testvm4.vmxf",
    "[nfs-b] testvm4/testvm4.vmdk"
    ],
    "hw_folder": "/datacenter1/vm/terraform-deploy",
    "hw_guest_full_name": "CentOS 7 (64-bit)",
    "hw_guest_ha_state": null,
    "hw_guest_id": "centos7_64Guest",
    "hw_interfaces": [
    "eth0"
    ],
    "hw_is_template": false,
    "hw_memtotal_mb": 512,
    "hw_name": "testvm4",
    "hw_power_status": "poweredOn",
    "hw_processor_count": 1,
    "hw_product_uuid": "42387ae9-cac5-1faa-1e84-0859533dd2b0",
    "instance_uuid": "5038a877-e2db-1bfd-6439-78f6522a9049",
    "ipv4": "192.168.1.12",
    "ipv6": "fe80::250:56ff:feb8:d51c",
    "module_hw": true,
    "snapshots": []
    ,
    "invocation":
    "module_args":
    "datacenter": "datacenter1",
    "folder": "/vm",
    "hostname": "vcenter.rum.local",
    "name": "testvm4",
    "name_match": "first",
    "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
    "port": 443,
    "username": "administrator@vsphere.local",
    "uuid": null,
    "validate_certs": false

    ,
    "item":
    "key": "testvm4",
    "value":
    "cpu": 1,
    "datastore": "nfs-b",
    "mem": 512,
    "network": "T1-PRD",
    "vmfolder": "terraform-deploy"


    ,

    "_ansible_ignore_errors": null,
    "_ansible_item_result": true,
    "_ansible_no_log": false,
    "_ansible_parsed": true,
    "changed": false,
    "failed": false,
    "instance":
    "annotation": "",
    "current_snapshot": null,
    "customvalues": ,
    "guest_consolidation_needed": false,
    "guest_question": null,
    "guest_tools_status": "guestToolsRunning",
    "guest_tools_version": "10304",
    "hw_cores_per_socket": 1,
    "hw_datastores": [
    "nfs-a"
    ],
    "hw_esxi_host": "esx-a.rum.local",
    "hw_eth0":
    "addresstype": "assigned",
    "ipaddresses": [
    "192.168.1.16",
    "fe80::250:56ff:feb8:5e2c"
    ],
    "label": "Network adapter 1",
    "macaddress": "00:50:56:b8:5e:2c",
    "macaddress_dash": "00-50-56-b8-5e-2c",
    "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
    ,
    "hw_files": [
    "[nfs-a] testvm3/testvm3.vmx",
    "[nfs-a] testvm3/testvm3.nvram",
    "[nfs-a] testvm3/testvm3.vmsd",
    "[nfs-a] testvm3/testvm3.vmxf",
    "[nfs-a] testvm3/testvm3.vmdk"
    ],
    "hw_folder": "/datacenter1/vm/terraform-deploy",
    "hw_guest_full_name": "CentOS 7 (64-bit)",
    "hw_guest_ha_state": null,
    "hw_guest_id": "centos7_64Guest",
    "hw_interfaces": [
    "eth0"
    ],
    "hw_is_template": false,
    "hw_memtotal_mb": 756,
    "hw_name": "testvm3",
    "hw_power_status": "poweredOn",
    "hw_processor_count": 2,
    "hw_product_uuid": "4238b6c3-a81a-cb51-a816-b83627bfcab0",
    "instance_uuid": "5038a0b1-f75a-f8cb-a872-344afdb1bc6f",
    "ipv4": "192.168.1.16",
    "ipv6": "fe80::250:56ff:feb8:5e2c",
    "module_hw": true,
    "snapshots": []
    ,
    "invocation":
    "module_args":
    "datacenter": "datacenter1",
    "folder": "/vm",
    "hostname": "vcenter.rum.local",
    "name": "testvm3",
    "name_match": "first",
    "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
    "port": 443,
    "username": "administrator@vsphere.local",
    "uuid": null,
    "validate_certs": false

    ,
    "item":
    "key": "testvm3",
    "value":
    "cpu": 2,
    "datastore": "nfs-a",
    "mem": 756,
    "network": "T2-TEST",
    "vmfolder": "terraform-deploy"



    ]











    share|improve this question
























      1












      1








      1


      1






      I am writing a script where I deploy and configure VM's on a vSphere environment.



      After the deployment I want to gather the IP's of the VM's for DNS registration.
      Facts can be gathered for 2 or more VM's at the same time.
      But how do I then use the gathered data to output a VM name with IP address?



      For a single VM this works to get the IP, but when used with 2 VM's the variable is undefinied:



      - debug:
      var: vm_guest_facts.instance.ipv4


      Maybe my approach is wrong, but I am not really sure how else to do it.



      - name: Gather facts from recently deployed VM's

      vmware_guest_facts:
      validate_certs: False
      hostname: " vcenter_hostname "
      username: " vcenter_user "
      password: " vcenter_pass "
      datacenter: " datacenter "
      name: " item.key "
      register: vm_guest_facts
      with_dict: " vmdetails "

      - debug:
      var: vm_guest_facts


      Results (the hostname and folder is Terraform, but this example only uses Ansible):



      TASK [Gather facts from standalone ESXi server having datacenter as 'ha- 
      datacenter']

      ok: [terraform.rum.local] => (item='value': u'mem': 512, u'network': u'T1-
      PRD', u'datastore': u'nfs-b', u'cpu': 1, u'vmfolder': u'terraform-deploy',
      'key': u'testvm4')
      ok: [terraform.rum.local] => (item='value': u'mem': 756, u'network': u'T2-
      TEST', u'datastore': u'nfs-a', u'cpu': 2, u'vmfolder': u'terraform-deploy',
      'key': u'testvm3')

      TASK [debug]
      *************************************
      ok: [terraform.rum.local] =>
      "vm_guest_facts":
      "changed": false,
      "msg": "All items completed",
      "results": [

      "_ansible_ignore_errors": null,
      "_ansible_item_result": true,
      "_ansible_no_log": false,
      "_ansible_parsed": true,
      "changed": false,
      "failed": false,
      "instance":
      "annotation": "",
      "current_snapshot": null,
      "customvalues": ,
      "guest_consolidation_needed": false,
      "guest_question": null,
      "guest_tools_status": "guestToolsRunning",
      "guest_tools_version": "10304",
      "hw_cores_per_socket": 1,
      "hw_datastores": [
      "nfs-b",
      "nfs-a"
      ],
      "hw_esxi_host": "esx-a.rum.local",
      "hw_eth0":
      "addresstype": "assigned",
      "ipaddresses": [
      "192.168.1.12",
      "fe80::250:56ff:feb8:d51c"
      ],
      "label": "Network adapter 1",
      "macaddress": "00:50:56:b8:d5:1c",
      "macaddress_dash": "00-50-56-b8-d5-1c",
      "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
      ,
      "hw_files": [
      "[nfs-b] testvm4/testvm4.vmx",
      "[nfs-b] testvm4/testvm4.nvram",
      "[nfs-b] testvm4/testvm4.vmsd",
      "[nfs-b] testvm4/testvm4.vmxf",
      "[nfs-b] testvm4/testvm4.vmdk"
      ],
      "hw_folder": "/datacenter1/vm/terraform-deploy",
      "hw_guest_full_name": "CentOS 7 (64-bit)",
      "hw_guest_ha_state": null,
      "hw_guest_id": "centos7_64Guest",
      "hw_interfaces": [
      "eth0"
      ],
      "hw_is_template": false,
      "hw_memtotal_mb": 512,
      "hw_name": "testvm4",
      "hw_power_status": "poweredOn",
      "hw_processor_count": 1,
      "hw_product_uuid": "42387ae9-cac5-1faa-1e84-0859533dd2b0",
      "instance_uuid": "5038a877-e2db-1bfd-6439-78f6522a9049",
      "ipv4": "192.168.1.12",
      "ipv6": "fe80::250:56ff:feb8:d51c",
      "module_hw": true,
      "snapshots": []
      ,
      "invocation":
      "module_args":
      "datacenter": "datacenter1",
      "folder": "/vm",
      "hostname": "vcenter.rum.local",
      "name": "testvm4",
      "name_match": "first",
      "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "port": 443,
      "username": "administrator@vsphere.local",
      "uuid": null,
      "validate_certs": false

      ,
      "item":
      "key": "testvm4",
      "value":
      "cpu": 1,
      "datastore": "nfs-b",
      "mem": 512,
      "network": "T1-PRD",
      "vmfolder": "terraform-deploy"


      ,

      "_ansible_ignore_errors": null,
      "_ansible_item_result": true,
      "_ansible_no_log": false,
      "_ansible_parsed": true,
      "changed": false,
      "failed": false,
      "instance":
      "annotation": "",
      "current_snapshot": null,
      "customvalues": ,
      "guest_consolidation_needed": false,
      "guest_question": null,
      "guest_tools_status": "guestToolsRunning",
      "guest_tools_version": "10304",
      "hw_cores_per_socket": 1,
      "hw_datastores": [
      "nfs-a"
      ],
      "hw_esxi_host": "esx-a.rum.local",
      "hw_eth0":
      "addresstype": "assigned",
      "ipaddresses": [
      "192.168.1.16",
      "fe80::250:56ff:feb8:5e2c"
      ],
      "label": "Network adapter 1",
      "macaddress": "00:50:56:b8:5e:2c",
      "macaddress_dash": "00-50-56-b8-5e-2c",
      "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
      ,
      "hw_files": [
      "[nfs-a] testvm3/testvm3.vmx",
      "[nfs-a] testvm3/testvm3.nvram",
      "[nfs-a] testvm3/testvm3.vmsd",
      "[nfs-a] testvm3/testvm3.vmxf",
      "[nfs-a] testvm3/testvm3.vmdk"
      ],
      "hw_folder": "/datacenter1/vm/terraform-deploy",
      "hw_guest_full_name": "CentOS 7 (64-bit)",
      "hw_guest_ha_state": null,
      "hw_guest_id": "centos7_64Guest",
      "hw_interfaces": [
      "eth0"
      ],
      "hw_is_template": false,
      "hw_memtotal_mb": 756,
      "hw_name": "testvm3",
      "hw_power_status": "poweredOn",
      "hw_processor_count": 2,
      "hw_product_uuid": "4238b6c3-a81a-cb51-a816-b83627bfcab0",
      "instance_uuid": "5038a0b1-f75a-f8cb-a872-344afdb1bc6f",
      "ipv4": "192.168.1.16",
      "ipv6": "fe80::250:56ff:feb8:5e2c",
      "module_hw": true,
      "snapshots": []
      ,
      "invocation":
      "module_args":
      "datacenter": "datacenter1",
      "folder": "/vm",
      "hostname": "vcenter.rum.local",
      "name": "testvm3",
      "name_match": "first",
      "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "port": 443,
      "username": "administrator@vsphere.local",
      "uuid": null,
      "validate_certs": false

      ,
      "item":
      "key": "testvm3",
      "value":
      "cpu": 2,
      "datastore": "nfs-a",
      "mem": 756,
      "network": "T2-TEST",
      "vmfolder": "terraform-deploy"



      ]











      share|improve this question














      I am writing a script where I deploy and configure VM's on a vSphere environment.



      After the deployment I want to gather the IP's of the VM's for DNS registration.
      Facts can be gathered for 2 or more VM's at the same time.
      But how do I then use the gathered data to output a VM name with IP address?



      For a single VM this works to get the IP, but when used with 2 VM's the variable is undefinied:



      - debug:
      var: vm_guest_facts.instance.ipv4


      Maybe my approach is wrong, but I am not really sure how else to do it.



      - name: Gather facts from recently deployed VM's

      vmware_guest_facts:
      validate_certs: False
      hostname: " vcenter_hostname "
      username: " vcenter_user "
      password: " vcenter_pass "
      datacenter: " datacenter "
      name: " item.key "
      register: vm_guest_facts
      with_dict: " vmdetails "

      - debug:
      var: vm_guest_facts


      Results (the hostname and folder is Terraform, but this example only uses Ansible):



      TASK [Gather facts from standalone ESXi server having datacenter as 'ha- 
      datacenter']

      ok: [terraform.rum.local] => (item='value': u'mem': 512, u'network': u'T1-
      PRD', u'datastore': u'nfs-b', u'cpu': 1, u'vmfolder': u'terraform-deploy',
      'key': u'testvm4')
      ok: [terraform.rum.local] => (item='value': u'mem': 756, u'network': u'T2-
      TEST', u'datastore': u'nfs-a', u'cpu': 2, u'vmfolder': u'terraform-deploy',
      'key': u'testvm3')

      TASK [debug]
      *************************************
      ok: [terraform.rum.local] =>
      "vm_guest_facts":
      "changed": false,
      "msg": "All items completed",
      "results": [

      "_ansible_ignore_errors": null,
      "_ansible_item_result": true,
      "_ansible_no_log": false,
      "_ansible_parsed": true,
      "changed": false,
      "failed": false,
      "instance":
      "annotation": "",
      "current_snapshot": null,
      "customvalues": ,
      "guest_consolidation_needed": false,
      "guest_question": null,
      "guest_tools_status": "guestToolsRunning",
      "guest_tools_version": "10304",
      "hw_cores_per_socket": 1,
      "hw_datastores": [
      "nfs-b",
      "nfs-a"
      ],
      "hw_esxi_host": "esx-a.rum.local",
      "hw_eth0":
      "addresstype": "assigned",
      "ipaddresses": [
      "192.168.1.12",
      "fe80::250:56ff:feb8:d51c"
      ],
      "label": "Network adapter 1",
      "macaddress": "00:50:56:b8:d5:1c",
      "macaddress_dash": "00-50-56-b8-d5-1c",
      "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
      ,
      "hw_files": [
      "[nfs-b] testvm4/testvm4.vmx",
      "[nfs-b] testvm4/testvm4.nvram",
      "[nfs-b] testvm4/testvm4.vmsd",
      "[nfs-b] testvm4/testvm4.vmxf",
      "[nfs-b] testvm4/testvm4.vmdk"
      ],
      "hw_folder": "/datacenter1/vm/terraform-deploy",
      "hw_guest_full_name": "CentOS 7 (64-bit)",
      "hw_guest_ha_state": null,
      "hw_guest_id": "centos7_64Guest",
      "hw_interfaces": [
      "eth0"
      ],
      "hw_is_template": false,
      "hw_memtotal_mb": 512,
      "hw_name": "testvm4",
      "hw_power_status": "poweredOn",
      "hw_processor_count": 1,
      "hw_product_uuid": "42387ae9-cac5-1faa-1e84-0859533dd2b0",
      "instance_uuid": "5038a877-e2db-1bfd-6439-78f6522a9049",
      "ipv4": "192.168.1.12",
      "ipv6": "fe80::250:56ff:feb8:d51c",
      "module_hw": true,
      "snapshots": []
      ,
      "invocation":
      "module_args":
      "datacenter": "datacenter1",
      "folder": "/vm",
      "hostname": "vcenter.rum.local",
      "name": "testvm4",
      "name_match": "first",
      "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "port": 443,
      "username": "administrator@vsphere.local",
      "uuid": null,
      "validate_certs": false

      ,
      "item":
      "key": "testvm4",
      "value":
      "cpu": 1,
      "datastore": "nfs-b",
      "mem": 512,
      "network": "T1-PRD",
      "vmfolder": "terraform-deploy"


      ,

      "_ansible_ignore_errors": null,
      "_ansible_item_result": true,
      "_ansible_no_log": false,
      "_ansible_parsed": true,
      "changed": false,
      "failed": false,
      "instance":
      "annotation": "",
      "current_snapshot": null,
      "customvalues": ,
      "guest_consolidation_needed": false,
      "guest_question": null,
      "guest_tools_status": "guestToolsRunning",
      "guest_tools_version": "10304",
      "hw_cores_per_socket": 1,
      "hw_datastores": [
      "nfs-a"
      ],
      "hw_esxi_host": "esx-a.rum.local",
      "hw_eth0":
      "addresstype": "assigned",
      "ipaddresses": [
      "192.168.1.16",
      "fe80::250:56ff:feb8:5e2c"
      ],
      "label": "Network adapter 1",
      "macaddress": "00:50:56:b8:5e:2c",
      "macaddress_dash": "00-50-56-b8-5e-2c",
      "summary": "DVSwitch: 50 38 43 04 bb 97 81 76-81 51 a6 cd a4 39 2b 61"
      ,
      "hw_files": [
      "[nfs-a] testvm3/testvm3.vmx",
      "[nfs-a] testvm3/testvm3.nvram",
      "[nfs-a] testvm3/testvm3.vmsd",
      "[nfs-a] testvm3/testvm3.vmxf",
      "[nfs-a] testvm3/testvm3.vmdk"
      ],
      "hw_folder": "/datacenter1/vm/terraform-deploy",
      "hw_guest_full_name": "CentOS 7 (64-bit)",
      "hw_guest_ha_state": null,
      "hw_guest_id": "centos7_64Guest",
      "hw_interfaces": [
      "eth0"
      ],
      "hw_is_template": false,
      "hw_memtotal_mb": 756,
      "hw_name": "testvm3",
      "hw_power_status": "poweredOn",
      "hw_processor_count": 2,
      "hw_product_uuid": "4238b6c3-a81a-cb51-a816-b83627bfcab0",
      "instance_uuid": "5038a0b1-f75a-f8cb-a872-344afdb1bc6f",
      "ipv4": "192.168.1.16",
      "ipv6": "fe80::250:56ff:feb8:5e2c",
      "module_hw": true,
      "snapshots": []
      ,
      "invocation":
      "module_args":
      "datacenter": "datacenter1",
      "folder": "/vm",
      "hostname": "vcenter.rum.local",
      "name": "testvm3",
      "name_match": "first",
      "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "port": 443,
      "username": "administrator@vsphere.local",
      "uuid": null,
      "validate_certs": false

      ,
      "item":
      "key": "testvm3",
      "value":
      "cpu": 2,
      "datastore": "nfs-a",
      "mem": 756,
      "network": "T2-TEST",
      "vmfolder": "terraform-deploy"



      ]








      ansible vmware-vcenter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 25 '18 at 19:35









      EwtEwt

      135




      135




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You might want to use json_query like this. Here, I am gathering facts from vmware_guest_facts and registering output in no_vm_result. Then, using this no_vm_result with json_query to iterate over all results and grabbing ipv4 which can be used to do anything. This is pretty straight forward thing.



          ---
          - name: StackOverflow answer
          gather_facts: no
          vars_files:
          - vcsim_vars.yml
          vars:
          vm_list:
          - DC0_H0_VM0
          - DC0_H0_VM1
          hosts: localhost
          tasks:
          - name: Gather VMware guest facts
          vmware_guest_facts:
          hostname: " vcenter_server "
          username: " vcenter_user "
          password: " vcenter_pass "
          datacenter: DC0
          validate_certs: no
          name: " item "
          register: no_vm_result
          with_items: " vm_list "

          - name: Get IPv4 address of VMs to add to DNS configuration
          debug:
          msg: " json_query(s_query) "
          vars:
          s_query: "[?instance.hw_name == ' item '].instance.ipv4"
          with_items: " vm_list "





          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f913846%2fansible-vmware-guest-facts-use-facts-for-multple-vms%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You might want to use json_query like this. Here, I am gathering facts from vmware_guest_facts and registering output in no_vm_result. Then, using this no_vm_result with json_query to iterate over all results and grabbing ipv4 which can be used to do anything. This is pretty straight forward thing.



            ---
            - name: StackOverflow answer
            gather_facts: no
            vars_files:
            - vcsim_vars.yml
            vars:
            vm_list:
            - DC0_H0_VM0
            - DC0_H0_VM1
            hosts: localhost
            tasks:
            - name: Gather VMware guest facts
            vmware_guest_facts:
            hostname: " vcenter_server "
            username: " vcenter_user "
            password: " vcenter_pass "
            datacenter: DC0
            validate_certs: no
            name: " item "
            register: no_vm_result
            with_items: " vm_list "

            - name: Get IPv4 address of VMs to add to DNS configuration
            debug:
            msg: " json_query(s_query) "
            vars:
            s_query: "[?instance.hw_name == ' item '].instance.ipv4"
            with_items: " vm_list "





            share|improve this answer



























              0














              You might want to use json_query like this. Here, I am gathering facts from vmware_guest_facts and registering output in no_vm_result. Then, using this no_vm_result with json_query to iterate over all results and grabbing ipv4 which can be used to do anything. This is pretty straight forward thing.



              ---
              - name: StackOverflow answer
              gather_facts: no
              vars_files:
              - vcsim_vars.yml
              vars:
              vm_list:
              - DC0_H0_VM0
              - DC0_H0_VM1
              hosts: localhost
              tasks:
              - name: Gather VMware guest facts
              vmware_guest_facts:
              hostname: " vcenter_server "
              username: " vcenter_user "
              password: " vcenter_pass "
              datacenter: DC0
              validate_certs: no
              name: " item "
              register: no_vm_result
              with_items: " vm_list "

              - name: Get IPv4 address of VMs to add to DNS configuration
              debug:
              msg: " json_query(s_query) "
              vars:
              s_query: "[?instance.hw_name == ' item '].instance.ipv4"
              with_items: " vm_list "





              share|improve this answer

























                0












                0








                0







                You might want to use json_query like this. Here, I am gathering facts from vmware_guest_facts and registering output in no_vm_result. Then, using this no_vm_result with json_query to iterate over all results and grabbing ipv4 which can be used to do anything. This is pretty straight forward thing.



                ---
                - name: StackOverflow answer
                gather_facts: no
                vars_files:
                - vcsim_vars.yml
                vars:
                vm_list:
                - DC0_H0_VM0
                - DC0_H0_VM1
                hosts: localhost
                tasks:
                - name: Gather VMware guest facts
                vmware_guest_facts:
                hostname: " vcenter_server "
                username: " vcenter_user "
                password: " vcenter_pass "
                datacenter: DC0
                validate_certs: no
                name: " item "
                register: no_vm_result
                with_items: " vm_list "

                - name: Get IPv4 address of VMs to add to DNS configuration
                debug:
                msg: " json_query(s_query) "
                vars:
                s_query: "[?instance.hw_name == ' item '].instance.ipv4"
                with_items: " vm_list "





                share|improve this answer













                You might want to use json_query like this. Here, I am gathering facts from vmware_guest_facts and registering output in no_vm_result. Then, using this no_vm_result with json_query to iterate over all results and grabbing ipv4 which can be used to do anything. This is pretty straight forward thing.



                ---
                - name: StackOverflow answer
                gather_facts: no
                vars_files:
                - vcsim_vars.yml
                vars:
                vm_list:
                - DC0_H0_VM0
                - DC0_H0_VM1
                hosts: localhost
                tasks:
                - name: Gather VMware guest facts
                vmware_guest_facts:
                hostname: " vcenter_server "
                username: " vcenter_user "
                password: " vcenter_pass "
                datacenter: DC0
                validate_certs: no
                name: " item "
                register: no_vm_result
                with_items: " vm_list "

                - name: Get IPv4 address of VMs to add to DNS configuration
                debug:
                msg: " json_query(s_query) "
                vars:
                s_query: "[?instance.hw_name == ' item '].instance.ipv4"
                with_items: " vm_list "






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 10 '18 at 11:41









                Abhijeet KasurdeAbhijeet Kasurde

                895720




                895720



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f913846%2fansible-vmware-guest-facts-use-facts-for-multple-vms%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                    Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                    Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020