-
Bug
-
Resolution: Duplicate
-
Undefined
-
None
-
Unspecified
-
False
-
-
False
-
-
https://github.com/ansible-collections/vmware.vmware_rest/issues/359
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete all sections as described, this form is processed automatically -->
-
-
-
-
- SUMMARY
<!--- Explain the problem briefly below -->
The datastore_moid lookup only ever returns an empty string when all datastores are in datastore clusters.
- SUMMARY
-
-
-
-
-
-
-
- ISSUE TYPE
-
-
-
- Bug Report
-
-
-
-
- COMPONENT NAME
<!--- Write the short name of the module, plugin, task or feature below, use your best guess if unsure -->
vmware.vmware_rest.datastore_moid
- COMPONENT NAME
-
-
-
-
-
-
-
- ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible [core 2.13.4]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.6 (default, Aug 11 2021, 06:39:25) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
jinja version = 3.0.3
libyaml = True
```
- ANSIBLE VERSION
-
-
-
- /usr/local/lib/python3.9/site-packages/ansible_collections
Collection Version-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -------
vmware.vmware_rest 2.2.0
- -------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /usr/share/ansible/collections/ansible_collections
Collection Version-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -------
vmware.vmware_rest 2.2.0
- -------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
```
-
-
-
-
- CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below
tc_vmware_nsxt_ansible # ansible-config dump --only-changed
ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True
DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = This file is managed by Ansible
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = community.general.yaml
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 60
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
```
- CONFIGURATION
-
-
-
-
-
-
-
- OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
vCenter: VMware vCenter Server 7.0.3 build-19717403
OS: Red Hat Enterprise Linux release 8.5 (Ootpa)
- OS / ENVIRONMENT
-
-
-
This is a container running in docker on a Redhat 7 host. Python 3.9 is installed with microdnf and all packages are install with python3 -m pip install. No venv or virtualenv is in use.
aiohttp 3.8.3
As the network_moid and cluster_moid work as expected, I am 100% confident that it is not an OS / environment issue.
-
-
-
-
- STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
Run a simple ansible.builtin.debug as demonstrated below, using the datastore_moid lookup. I have included a network_moid lookup test to show that other lookups work as expected.
- STEPS TO REPRODUCE
-
-
-
<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: Test vmware_rest lookups
hosts: "localhost"
gather_facts: false
vars:
vcenter_credentials:
vcenter_hostname: "{{ vc_hostname }}"
vcenter_password: "{{ vc_password}}"
vcenter_username: "{{ vc_username }}"
vcenter_validate_certs: false
tasks:
- name: Rest lookup
ansible.builtin.debug:
msg: - "network: {{ lookup('vmware.vmware_rest.network_moid', '/datacenter/network/network_name', **vcenter_credentials) }}"
- "datastore: {{ lookup('vmware.vmware_rest.datastore_moid', '/datacenter/datastore/datastore_name', **vcenter_credentials) }}"
- "datastore with ds cluster: {{ lookup('vmware.vmware_rest.datastore_moid', '/datacenter/datastore/datastore_cluster_name/datastore_name', **vcenter_credentials) }}"
```
<!--- HINT: You can paste gist.github.com links for larger files -->
-
-
-
-
- EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
Expected result is the datastore_moid returns the moref of the datastore.
- EXPECTED RESULTS
-
-
-
-
-
-
-
- ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
As can be seen from the output below, the network_moid (path: /datacenter/network/network_name) has returned a moref as expected but either format of the datastore_moid lookup is returning an empty string. I would expect the need for the path to include the datastore cluster therefore the output of datastore without ds cluster is probably correct. I include it just to show I have tried many logical combinations but all return an empty string.
I can see from the log (if necessary, I can post but will have to sanitise) the recursion finds the datastore folder but then doesn't recurse any further because the only child entities in the folder are storagepod objects (datastore clusters).
- ACTUAL RESULTS
-
-
-
<!--- Paste verbatim command output between quotes -->
```paste below
PLAY [Test vmware_rest lookups] ****************************************************************************************************************************************************
[started TASK: vmware_rest lookup on localhost]
TASK [vmware_rest lookup] **********************************************************************************************************************************************************
ok: [localhost] =>
msg:
- 'network: dvportgroup-1024'
- 'datastore: '
- 'datastore: '
PLAY RECAP *************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
```
Using the vCenter MOB, this is the path taken to get to the relevant datastore from the home page:
> content > rootFolder: group-d1 (Datacenters) > childEntity: datacenter-1001 (###) > datastoreFolder: group-s1004 (datastore) > childEntity: group-p1012 (###) > childEntity: datastore-2009 (###)
Object types for each moref:
group-d1 : ManagedObjectReference:Folder
datacenter-1001 : ManagedObjectReference:Datacenter
group-s1004 : ManagedObjectReference:Folder
group-p1012 : ManagedObjectReference:StoragePod
datastore-2009 : ManagedObjectReference:Datastore
Sorry I can not post actual names for either the path or the mob output but trust I have double checked (copied/pasted from the mob) that the names in the playbook are the names in the mob.
As this is my first time raising an issue, as well as feedback on the actual issue I am more than happy to take feedback on the content I have included. I hope I have demonstrated a level of understanding that you can trust but if this is too much detail then please let me know.