Skip to content

VMware variable consistency #1538

Open
Open
@adam-kosseck

Description

@adam-kosseck
SUMMARY

When using a VMware inventory source in the Ansible GUI, Ansible does not accept variables and values as per the VMware API. Ansible seems to only accept ansible-specific versions of these variables and values.

For example in the VMware API there is a variable summary.runtime.powerState which has a value of either poweredOn or poweredOff.
This variable and its values are used verbatim in the community.vmware inventory (which I run from the Ansible CLI regularly), however in the Ansible GUI when you configure a VMware inventory source you must use different variables and values - there appears to be some sort of internal mapping going on.

For example:
VMware API variable summary.runtime.powerState maps to AWX GUI value status.power_state
and VMware API variable value poweredOn/poweredOff map to AWX GUI powered_on/powered_off

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Inventory or the GUI implementation thereof

ANSIBLE VERSION
ansible [core 2.13.3]
confi file = /etc/ansible/ansible.cfg
configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/username/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
5.3.0.  This is likely different from the version used in the UI

CONFIGURATION

no output

OS / ENVIRONMENT

RHEL 8

STEPS TO REPRODUCE

When you put the details as per the API in the "Enabled Variable" and "Enabled Value" fields in the GUI for the inventory source, and add a hostname filter Ansible throws an error during inventory updates:

ansible-inventory [core 2.13.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
  executable location = /usr/bin/ansible-inventory
  python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 [20210514](https://access.redhat.com/support/cases/#/case/20210514) (Red Hat 8.5.0-3)]
  jinja version = 3.0.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
redirecting (type: inventory) ansible.builtin.vmware_vm_inventory to community.vmware.vmware_vm_inventory
Loading collection community.vmware from /usr/share/automation-controller/collections/ansible_collections/community/vmware
Using inventory plugin 'ansible_collections.community.vmware.plugins.inventory.vmware_vm_inventory' to process inventory source '/runner/inventory/vmware_vm_inventory.yml'
[WARNING]:  * Failed to parse /runner/inventory/vmware_vm_inventory.yml with
auto plugin: Could not template any hostname for host, errors for each
preference: config.name: 'config' is undefined
  File "/usr/lib/python3.9/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.9/site-packages/ansible/plugins/inventory/auto.py", line 59, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/usr/share/automation-controller/collections/ansible_collections/community/vmware/plugins/inventory/vmware_vm_inventory.py", line 747, in parse
    cacheable_results = self._populate_from_source()
File "/usr/share/automation-controller/collections/ansible_collections/community/vmware/plugins/inventory/vmware_vm_inventory.py", line 853, in _populate_from_source
    host = self._get_hostname(host_properties, hostnames, strict=strict)
  File "/usr/share/automation-controller/collections/ansible_collections/community/vmware/plugins/inventory/vmware_vm_inventory.py", line 880, in _get_hostname
    raise AnsibleError(
[WARNING]: Unable to parse /runner/inventory/vmware_vm_inventory.yml as an
inventory source
ERROR! No inventory was parsed, please check your configuration and options.

If I remove the hostname filter then the inventory source starts working again, however it is not filtered correctly (Based on variable/value) and throws a warning for each host found: "WARNING HOST "xxxx" has no "config.instanceUuid, config.instanceuuid" variable(s)".

If I view an existing host in the GUI Inventory section, under the variables tab of the host I see:
"summary.runtime.powerState": "poweredOn",

However if I look in the AWX documentation (https://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html) I see different values, e.g. :
"power_state": "powered_on".

The minute I change the "Enabled Variable" and "Enabled Value" fields to use the GUI-specific mapped values, the inventory works correctly without error or warning.

EXPECTED RESULTS

GUI to use the same variables/values as per the CLI Ansible vmware inventory implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugneeds_triageNeeds a first human triage before being processed.python3traceback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions