vmware_tools – Execute tasks inside a VM via VMware Tools
New in version 2.8.
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
topowershell
. - Does not work with ‘become’.
Requirements
The below requirements are needed on the local master node that executes this connection.
- pyvmomi (Python library)
- requests (Python library)
Parameters
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
exec_command_sleep_interval
float
|
Default:
0.5
|
var: ansible_vmware_tools_exec_command_sleep_interval
|
Time in seconds to sleep between execution of command.
|
executable
-
|
Default:
"/bin/sh"
|
ini entries:
[defaults]
env:ANSIBLE_EXECUTABLE
var: ansible_executable
var: ansible_vmware_tools_executable
|
shell to use for execution inside container
|
file_chunk_size
integer
|
Default:
128
|
var: ansible_vmware_tools_file_chunk_size
|
File chunk size.
(Applicable when writing a file to disk, example: using the
fetch module.)
|
validate_certs
boolean
|
|
env:VMWARE_VALIDATE_CERTS
var: ansible_vmware_validate_certs
|
Verify SSL for the connection.
Note: This will validate certs for both
vmware_host and the ESXi host running the VM.
|
vm_password
- /
required
|
var: ansible_password
var: ansible_vmware_tools_password
|
Password for the user in guest operating system.
|
|
vm_path
- /
required
|
var: ansible_vmware_guest_path
|
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
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.
|
|
vm_user
- /
required
|
var: ansible_user
var: ansible_vmware_tools_user
|
VM username.
|
|
vmware_host
- /
required
|
env:VI_SERVER
env:VMWARE_HOST
var: ansible_host
var: ansible_vmware_host
|
FQDN or IP Address for the connection (vCenter or ESXi Host).
|
|
vmware_password
- /
required
|
env:VI_PASSWORD
env:VMWARE_PASSWORD
var: ansible_vmware_password
|
Password for the connection.
|
|
vmware_port
-
|
Default:
443
|
env:VI_PORTNUMBER
env:VMWARE_PORT
var: ansible_port
var: ansible_vmware_port
|
Port for the connection.
|
vmware_user
- /
required
|
env:VI_USERNAME
env:VMWARE_USER
var: ansible_vmware_user
|
Username for the connection.
Requires the following permissions on the VM: - VirtualMachine.GuestOperations.Execute - VirtualMachine.GuestOperations.Modify - VirtualMachine.GuestOperations.Query
|
Examples
# example vars.yml --- ansible_connection: vmware_tools ansible_vmware_host: vcenter.example.com ansible_vmware_user: [email protected] ansible_vmware_password: Secr3tP4ssw0rd!12 ansible_vmware_validate_certs: no # default is yes # vCenter Connection VM Path Example ansible_vmware_guest_path: DATACENTER/vm/FOLDER/{{ inventory_hostname }} # ESXi Connection VM Path Example ansible_vmware_guest_path: ha-datacenter/vm/{{ inventory_hostname }} ansible_vmware_tools_user: root ansible_vmware_tools_password: MyR00tPassw0rD # if the target VM guest is Windows set the 'ansible_shell_type' to 'powershell' ansible_shell_type: powershell # example playbook_linux.yml --- - name: Test VMware Tools Connection Plugin for Linux hosts: linux tasks: - command: whoami - ping: - copy: src: foo dest: /home/user/foo - fetch: src: /home/user/foo dest: linux-foo flat: yes - file: path: /home/user/foo state: absent # example playbook_windows.yml --- - name: Test VMware Tools Connection Plugin for Windows hosts: windows tasks: - win_command: whoami - win_ping: - win_copy: src: foo dest: C:\Users\user\foo - fetch: src: C:\Users\user\foo dest: windows-foo flat: yes - win_file: path: C:\Users\user\foo state: absent
Status
- This connection is not guaranteed to have a backwards compatible interface. [preview]
- This connection is maintained by the Ansible Community. [community]
Authors
- Deric Crago <deric.crago@gmail.com>
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/plugins/connection/vmware_tools.html