Skip to content

Latest commit

 

History

History
233 lines (197 loc) · 8.59 KB

vmware.vmware_rest.datastore_moid_lookup.rst

File metadata and controls

233 lines (197 loc) · 8.59 KB

vmware.vmware_rest.datastore_moid

Look up MoID for vSphere datastore objects using vCenter REST API

Version added: 2.1.0

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 Ansible controller node that executes this lookup.

  • vSphere 7.0.2 or greater
  • python >= 3.6
  • aiohttp

Parameters

Parameter Choices/Defaults Configuration Comments
_terms
- / required
Path to query.
vcenter_hostname
string / required
The hostname or IP address of the vSphere vCenter.
If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.
vcenter_password
string / required
The vSphere vCenter password.
If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.
vcenter_rest_log_file
string
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 VMWARE_REST_LOG_FILE will be used instead.
vcenter_username
string / required
The vSphere vCenter username.
If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.
vcenter_validate_certs
boolean
    Choices:
  • no
  • yes ←
Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.
If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Examples

# 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/') }}"

Return Values

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


Status

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.