vmware.vmware_rest.datastore_moid lookup – Look up MoID for vSphere datastore objects using vCenter REST API
Note
This lookup plugin is part of the vmware.vmware_rest collection (version 2.2.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install vmware.vmware_rest
.
To use it in a playbook, specify: vmware.vmware_rest.datastore_moid
.
New in version 2.1.0: of vmware.vmware_rest
Synopsis
Returns Managed Object Reference (MoID) of the vSphere datastore object object contained in the specified path.
Requirements
The below requirements are needed on the local controller node that executes this lookup.
vSphere 7.0.2 or greater
python >= 3.6
aiohttp
Parameters
Parameter |
Comments |
---|---|
Path to query. |
|
The hostname or IP address of the vSphere vCenter. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter password. If the value is not specified in the task, the value of environment variable |
|
You can use this optional parameter to set the location of a log file. This file will be used to record the HTTP REST interaction. The file will be stored on the host that run the module. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter username. If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
Examples
# lookup sample
- name: set connection info
ansible.builtin.set_fact:
connection_args:
vcenter_hostname: "vcenter.test"
vcenter_username: "[email protected]"
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/') }}"
Return Values
Common return values are documented here, the following are the fields unique to this lookup:
Key |
Description |
---|---|
MoID of the vSphere datastore object Returned: success Sample: “datastore-1019” |
Authors
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.