Look up MoID for vSphere datastore objects using vCenter REST API
Version added: 2.1.0
- Returns Managed Object Reference (MoID) of the vSphere datastore object object contained in the specified path.
The below requirements are needed on the local Ansible controller node that executes this lookup.
- vSphere 7.0.2 or greater
- python >= 3.6
- aiohttp
# lookup sample
- name: set connection info
ansible.builtin.set_fact:
connection_args:
vcenter_hostname: "vcenter.test"
vcenter_username: "administrator@vsphere.local"
vcenter_password: "1234"
- name: lookup MoID of the object
ansible.builtin.debug: msg="{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/host/my_cluster/esxi1.test/ro_datastore', **connection_args) }}"
- name: lookup MoID of the object inside the path
ansible.builtin.debug: msg="{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/') }}"
Common return values are documented here, the following are the fields unique to this lookup:
Key | Returned | Description |
---|---|---|
_raw
string
|
MoID of the vSphere datastore object
Sample:
datastore-1019
|
- Alina Buzachis (@alinabuzachis)
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.