community.vmware.vmware_tools – Execute tasks inside a VM via VMware Tools

Note

This plugin is part of the community.vmware collection (version 1.17.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.vmware.

To use it in a playbook, specify: community.vmware.vmware_tools.

Synopsis

  • Use VMware tools to run tasks in, or put/fetch files to guest operating systems running in VMware infrastructure.

  • In case of Windows VMs, set ansible_shell_type to powershell.

  • Does not work with ‘become’.

Requirements

The below requirements are needed on the local controller node that executes this connection.

  • pyvmomi (Python library)

  • requests (Python library)

Parameters

Parameter

Comments

exec_command_sleep_interval

float

Time in seconds to sleep between execution of command.

Default: 0.5

Configuration:

  • Variable: ansible_vmware_tools_exec_command_sleep_interval

executable

string

shell to use for execution inside container

Default: “/bin/sh”

Configuration:

  • INI entry:

    [defaults]
    executable = /bin/sh
    
  • Environment variable: ANSIBLE_EXECUTABLE

  • Variable: ansible_executable

  • Variable: ansible_vmware_tools_executable

file_chunk_size

integer

File chunk size.

(Applicable when writing a file to disk, example: using the fetch module.)

Default: 128

Configuration:

  • Variable: ansible_vmware_tools_file_chunk_size

validate_certs

boolean

Verify SSL for the connection.

Note: This will validate certs for both vmware_host and the ESXi host running the VM.

Choices:

  • no

  • yes ← (default)

Configuration:

  • Environment variable: VMWARE_VALIDATE_CERTS

  • Variable: ansible_vmware_validate_certs

vm_password

string / required

Password for the user in guest operating system.

Configuration:

  • Variable: ansible_password

  • Variable: ansible_vmware_tools_password

vm_path

string / required

VM path absolute to the connection.

vCenter Example: Datacenter/vm/Discovered virtual machine/testVM.

ESXi Host Example: ha-datacenter/vm/testVM.

Must include VM name, appended to ‘folder’ as would be passed to community.vmware.vmware_guest.

Needs to include vm between the Datacenter and the rest of the VM path.

Datacenter default value for ESXi server is ha-datacenter.

Folder vm is not visible in the vSphere Web Client but necessary for VMware API to work.

Configuration:

  • Variable: ansible_vmware_guest_path

vm_user

string / required

VM username.

Configuration:

  • Variable: ansible_user

  • Variable: ansible_vmware_tools_user

vmware_host

string / required

FQDN or IP Address for the connection (vCenter or ESXi Host).

Configuration:

  • Environment variable: VI_SERVER

  • Environment variable: VMWARE_HOST

  • Variable: ansible_host

  • Variable: ansible_vmware_host

vmware_password

string / required

Password for the connection.

Configuration:

  • Environment variable: VI_PASSWORD

  • Environment variable: VMWARE_PASSWORD

  • Variable: ansible_vmware_password

vmware_port

string

Port for the connection.

Default: 443

Configuration:

  • Environment variable: VI_PORTNUMBER

  • Environment variable: VMWARE_PORT

  • Variable: ansible_port

  • Variable: ansible_vmware_port

vmware_user

string / required

Username for the connection.

Requires the following permissions on the VM: - VirtualMachine.GuestOperations.Execute - VirtualMachine.GuestOperations.Modify - VirtualMachine.GuestOperations.Query

Configuration:

  • Environment variable: VI_USERNAME

  • Environment variable: VMWARE_USER

  • Variable: ansible_vmware_user

Authors