community.vmware.vmware_vm_inventory (4.2.0) — inventory

VMware Guest inventory source

Authors: Abhijeet Kasurde (@Akasurde)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

Get virtual machines as inventory hosts from VMware environment.

Uses any file which ends with vmware.yml, vmware.yaml, vmware_vm_inventory.yml, or vmware_vm_inventory.yaml as a YAML configuration file.


Requirements

Inputs

    
port:
    default: 443
    description: Port number used to connect to vCenter or ESXi Server.
    env:
    - name: VMWARE_PORT
    type: int

cache:
    default: false
    description:
    - Toggle to enable/disable the caching of the inventory's source data, requires a
      cache plugin setup to work.
    env:
    - name: ANSIBLE_INVENTORY_CACHE
    ini:
    - key: cache
      section: inventory
    type: bool

groups:
    default: {}
    description: Add hosts to group based on Jinja2 conditionals.
    type: dict

strict:
    default: false
    description:
    - If V(yes) make invalid entries a fatal error, otherwise skip and continue.
    - Since it is possible to use facts in the expressions they might not always be available
      and we ignore those errors by default.
    type: bool

compose:
    default: {}
    description: Create vars from jinja2 expressions.
    type: dict

filters:
    default: []
    description:
    - This option allows client-side filtering hosts with jinja templating.
    - When server-side filtering is introduced, it should be preferred over this.
    elements: str
    type: list

hostname:
    description: Name of vCenter or ESXi server.
    env:
    - name: VMWARE_HOST
    - name: VMWARE_SERVER
    required: true

password:
    description:
    - Password of vSphere user.
    - Accepts vault encrypted variable.
    - Accepts Jinja to template the value
    env:
    - name: VMWARE_PASSWORD
    required: true

username:
    description:
    - Name of vSphere user.
    - Accepts vault encrypted variable.
    - Accepts Jinja to template the value
    env:
    - name: VMWARE_USER
    - name: VMWARE_USERNAME
    required: true

hostnames:
    default:
    - config.name + "_" + config.uuid
    description:
    - A list of templates in order of precedence to compose inventory_hostname.
    - Ignores template if resulted in an empty string or None value.
    - You can use property specified in O(properties) as variables in the template.
    elements: string
    type: list

resources:
    default: []
    description:
    - A list of resources to limit search scope.
    - Each resource item is represented by exactly one C('vim_type_snake_case):C(list
      of resource names) pair and optional nested I(resources)
    - Key name is based on snake case of a vim type name; e.g V(host_system) correspond
      to C(vim.HostSystem)
    - See  L(VIM Types,https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/index-mo_types.html)
    elements: dict
    required: false
    type: list

with_path:
    default: false
    description:
    - Include virtual machines path.
    - Set this option to a string value to replace root name from I('Datacenters').
    type: bool

with_tags:
    default: false
    description:
    - Include tags and associated virtual machines.
    - Requires 'vSphere Automation SDK' library to be installed on the given controller
      machine.
    - Please refer following URLs for installation steps
    - U(https://code.vmware.com/web/sdk/7.0/vsphere-automation-python)
    type: bool

properties:
    default:
    - name
    - config.cpuHotAddEnabled
    - config.cpuHotRemoveEnabled
    - config.instanceUuid
    - config.hardware.numCPU
    - config.template
    - config.name
    - config.uuid
    - guest.hostName
    - guest.ipAddress
    - guest.guestId
    - guest.guestState
    - runtime.maxMemoryUsage
    - customValue
    - summary.runtime.powerState
    - config.guestId
    description:
    - Specify the list of VMware schema properties associated with the VM.
    - These properties will be populated in hostvars of the given VM.
    - Each value in the list can be a path to a specific property in VM object or a path
      to a collection of VM objects.
    - V(config.name), V(config.uuid) are required properties if O(hostnames) is set to
      default.
    - V(config.guestId), V(summary.runtime.powerState) are required if O(keyed_groups)
      is set to default.
    - Please make sure that all the properties that are used in other parameters are included
      in this options.
    - In addition to VM properties, the following are special values
    - Use V(customValue) to populate virtual machine's custom attributes. V(customValue)
      is only supported by vCenter and not by ESXi.
    - Use V(all) to populate all the properties of the virtual machine. The value V(all)
      is time consuming operation, do not use unless required absolutely.
    - Please refer more VMware guest attributes which can be used as properties U(https://docs.ansible.com/ansible/latest/collections/community/vmware/docsite/vmware_scenarios/vmware_inventory_vm_attributes.html)
    elements: string
    type: list

proxy_host:
    description:
    - Address of a proxy that will receive all HTTPS requests and relay them.
    - The format is a hostname or a IP.
    env:
    - name: VMWARE_PROXY_HOST
    required: false
    type: str

proxy_port:
    description:
    - Port of the HTTP proxy that will receive all HTTPS requests and relay them.
    env:
    - name: VMWARE_PROXY_PORT
    required: false
    type: int

cache_plugin:
    default: memory
    description:
    - Cache plugin to use for the inventory's source data.
    env:
    - name: ANSIBLE_CACHE_PLUGIN
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN
    ini:
    - key: fact_caching
      section: defaults
    - key: cache_plugin
      section: inventory
    type: str

cache_prefix:
    default: ansible_inventory_
    description:
    - Prefix to use for cache plugin files/tables
    env:
    - name: ANSIBLE_CACHE_PLUGIN_PREFIX
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX
    ini:
    - key: fact_caching_prefix
      section: defaults
    - key: cache_prefix
      section: inventory

keyed_groups:
    default:
    - key: config.guestId
      separator: ''
    - key: summary.runtime.powerState
      separator: ''
    description:
    - Add hosts to group based on the values of a variable.
    elements: dict
    suboptions:
      default_value:
        description:
        - The default value when the host variable's value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].trailing_separator).
        type: str
        version_added: '2.12'
        version_added_collection: ansible.builtin
      key:
        description:
        - The key from input dictionary used to generate groups
        type: str
      parent_group:
        description: parent group for keyed group
        type: str
      prefix:
        default: ''
        description: A keyed group name will start with this prefix
        type: str
      separator:
        default: _
        description: separator used to build the keyed group name
        type: str
      trailing_separator:
        default: true
        description:
        - Set this option to V(False) to omit the O(keyed_groups[].separator) after the
          host variable when the value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].default_value).
        type: bool
        version_added: '2.12'
        version_added_collection: ansible.builtin
    type: list

cache_timeout:
    default: 3600
    description:
    - Cache duration in seconds
    env:
    - name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
    - name: ANSIBLE_INVENTORY_CACHE_TIMEOUT
    ini:
    - key: fact_caching_timeout
      section: defaults
    - key: cache_timeout
      section: inventory
    type: int

subproperties:
    default: []
    description:
    - List of subproperties from an normal property.
    - These subproperties will also populated to the hostvars of the given VM.
    elements: dict
    suboptions:
      property:
        description:
        - Name of the Property
        required: true
        type: str
      subelements:
        description:
        - List of subelements
        elements: str
        type: list
    type: list
    version_added: 4.2.0
    version_added_collection: community.vmware

use_extra_vars:
    default: false
    description: Merge extra vars into the available variables for composition (highest
      precedence).
    env:
    - name: ANSIBLE_INVENTORY_USE_EXTRA_VARS
    ini:
    - key: use_extra_vars
      section: inventory_plugins
    type: bool
    version_added: '2.11'
    version_added_collection: ansible.builtin

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid.
    - Set to V(false) when certificates are not trusted.
    env:
    - name: VMWARE_VALIDATE_CERTS
    type: bool

cache_connection:
    description:
    - Cache connection data or path, read cache plugin documentation for specifics.
    env:
    - name: ANSIBLE_CACHE_PLUGIN_CONNECTION
    - name: ANSIBLE_INVENTORY_CACHE_CONNECTION
    ini:
    - key: fact_caching_connection
      section: defaults
    - key: cache_connection
      section: inventory
    type: str

leading_separator:
    default: true
    description:
    - Use in conjunction with keyed_groups.
    - By default, a keyed group that does not have a prefix or a separator provided will
      have a name that starts with an underscore.
    - This is because the default prefix is "" and the default separator is "_".
    - Set this option to False to omit the leading underscore (or other separator) if
      no prefix is given.
    - If the group name is derived from a mapping the separator is still used to concatenate
      the items.
    - To not use a separator in the group name at all, set the separator for the keyed
      group to an empty string instead.
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin

with_nested_properties:
    default: true
    description:
    - This option transform flatten properties name to nested dictionary.
    type: bool

with_sanitized_property_name:
    default: false
    description:
    - This option allows property name sanitization to create safe property names for
      use in Ansible.
    - Also, transforms property name to snake case.
    type: bool