ansible / ansible.builtin / v2.9.3 / connection / vmware_tools Execute tasks inside a VM via VMware Tools | "added in version" 2.8 of ansible.builtin" Authors: Deric Crago <deric.crago@gmail.com>ansible.builtin.vmware_tools (v2.9.3) — connection
pip
Install with pip install ansible==2.9.3
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 C(ansible_shell_type) to C(powershell).
Does not work with 'become'.
# example vars.yml --- ansible_connection: vmware_tools ansible_vmware_host: vcenter.example.com ansible_vmware_user: administrator@vsphere.local 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 vars.yml --- ansible_connection: vmware_tools ansible_vmware_host: vcenter.example.com ansible_vmware_user: administrator@vsphere.local 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
vm_path: description: - VM path absolute to the connection. - 'vCenter Example: C(Datacenter/vm/Discovered virtual machine/testVM).' - 'ESXi Host Example: C(ha-datacenter/vm/testVM).' - Must include VM name, appended to 'folder' as would be passed to M(vmware_guest). - Needs to include I(vm) between the Datacenter and the rest of the VM path. - Datacenter default value for ESXi server is C(ha-datacenter). - Folder I(vm) is not visible in the vSphere Web Client but necessary for VMware API to work. required: true vars: - name: ansible_vmware_guest_path vm_user: description: - VM username. required: true vars: - name: ansible_user - name: ansible_vmware_tools_user executable: default: /bin/sh description: - shell to use for execution inside container env: - name: ANSIBLE_EXECUTABLE ini: - key: executable section: defaults vars: - name: ansible_executable - name: ansible_vmware_tools_executable vm_password: description: - Password for the user in guest operating system. required: true vars: - name: ansible_password - name: ansible_vmware_tools_password vmware_host: description: - FQDN or IP Address for the connection (vCenter or ESXi Host). env: - name: VI_SERVER - name: VMWARE_HOST required: true vars: - name: ansible_host - name: ansible_vmware_host vmware_port: default: 443 description: - Port for the connection. env: - name: VI_PORTNUMBER - name: VMWARE_PORT required: false vars: - name: ansible_port - name: ansible_vmware_port vmware_user: description: - Username for the connection. - 'Requires the following permissions on the VM: - VirtualMachine.GuestOperations.Execute - VirtualMachine.GuestOperations.Modify - VirtualMachine.GuestOperations.Query' env: - name: VI_USERNAME - name: VMWARE_USER required: true vars: - name: ansible_vmware_user validate_certs: default: true description: - Verify SSL for the connection. - 'Note: This will validate certs for both C(vmware_host) and the ESXi host running the VM.' env: - name: VMWARE_VALIDATE_CERTS type: bool vars: - name: ansible_vmware_validate_certs file_chunk_size: default: 128 description: - File chunk size. - '(Applicable when writing a file to disk, example: using the C(fetch) module.)' type: integer vars: - name: ansible_vmware_tools_file_chunk_size vmware_password: description: - Password for the connection. env: - name: VI_PASSWORD - name: VMWARE_PASSWORD required: true vars: - name: ansible_vmware_password exec_command_sleep_interval: default: 0.5 description: - Time in seconds to sleep between execution of command. type: float vars: - name: ansible_vmware_tools_exec_command_sleep_interval