The vmware_vm_shell module

This module can be used to connect to a virtual machine using VMware and to run a shell command. At no point does Ansible need to connect to the virtual machine using a network-based service such as SSH, making it useful for configuring VMs before they are on the network:

- name: Shell example  vmware_vm_shell:    hostname: "{{ vsphere_host }}"    username: "{{ vsphere_username }}"    password: "{{ vsphere_password }}"    datacenter: "my_datacenter"    folder: "/my_vms"    vm_id: "example_vm"    vm_username: "root"    vm_password: "supersecretpassword"    vm_shell: "/bin/cat"    vm_shell_args: " results_file "    vm_shell_env:      - "PATH=/bin"      - "VAR=test"    vm_shell_cwd: "/tmp"  delegate_to: "localhost"  register: shell_results

The previous example connects ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.