VMware Inventory Enhancements (#63938)

* Fixes #63937

* Add the environment variables VMWARE_HOST, VMWARE_USER, and VMWARE_VALIDATE_CERTS for consistency

* Follow the general pattern for config file naming requirements and update the documentation
pull/64300/head
willtome 5 years ago committed by Sloane Hertel
parent 6e07d4c1d9
commit bbbaf0dfe7

@ -16,7 +16,7 @@ DOCUMENTATION = '''
- Abhijeet Kasurde (@Akasurde) - Abhijeet Kasurde (@Akasurde)
description: description:
- Get virtual machines as inventory hosts from VMware environment. - Get virtual machines as inventory hosts from VMware environment.
- Uses any file which ends with vmware.yml or vmware.yaml as a YAML configuration file. - Uses any file which ends with vmware.yml, vmware.yaml, vmware_vm_inventory.yml, or vmware_vm_inventory.yaml as a YAML configuration file.
- The inventory_hostname is always the 'Name' and UUID of the virtual machine. UUID is added as VMware allows virtual machines with the same name. - The inventory_hostname is always the 'Name' and UUID of the virtual machine. UUID is added as VMware allows virtual machines with the same name.
extends_documentation_fragment: extends_documentation_fragment:
- inventory_cache - inventory_cache
@ -31,11 +31,13 @@ DOCUMENTATION = '''
description: Name of vCenter or ESXi server. description: Name of vCenter or ESXi server.
required: True required: True
env: env:
- name: VMWARE_HOST
- name: VMWARE_SERVER - name: VMWARE_SERVER
username: username:
description: Name of vSphere admin user. description: Name of vSphere admin user.
required: True required: True
env: env:
- name: VMWARE_USER
- name: VMWARE_USERNAME - name: VMWARE_USERNAME
password: password:
description: Password of vSphere admin user. description: Password of vSphere admin user.
@ -52,6 +54,8 @@ DOCUMENTATION = '''
- Allows connection when SSL certificates are not valid. Set to C(false) when certificates are not trusted. - Allows connection when SSL certificates are not valid. Set to C(false) when certificates are not trusted.
default: True default: True
type: boolean type: boolean
env:
- name: VMWARE_VALIDATE_CERTS
with_tags: with_tags:
description: description:
- Include tags and associated virtual machines. - Include tags and associated virtual machines.
@ -307,13 +311,11 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
Verify plugin configuration file and mark this plugin active Verify plugin configuration file and mark this plugin active
Args: Args:
path: Path of configuration YAML file path: Path of configuration YAML file
Returns: True if everything is correct, else False Returns: True if everything is correct, else False
""" """
valid = False valid = False
if super(InventoryModule, self).verify_file(path): if super(InventoryModule, self).verify_file(path):
if path.endswith(('vmware.yaml', 'vmware.yml')): if path.endswith(('vmware.yaml', 'vmware.yml', 'vmware_vm_inventory.yaml', 'vmware_vm_inventory.yml')):
valid = True valid = True
return valid return valid

Loading…
Cancel
Save