On this page
vmware_vm_shell - Execute a process in VM
New in version 2.1.
Synopsis
- Start a program in a VM without the need for network connection
 
Requirements (on host that executes module)
- python >= 2.6
 - PyVmomi
 
Options
| parameter | required | default | choices | comments | 
|---|---|---|---|---|
| cluster | 
      no | None | 
        
        The cluster hosting the VM
        
       
        Will help speed up search
         | 
     |
| datacenter | 
      no | None | 
        
        The datacenter hosting the VM
        
       
        Will help speed up search
         | 
     |
| folder 
        (added in 2.4)
         | 
      no | /vm | 
        
        Destination folder, absolute or relative path to find an existing guest or create the new guest.
        
       
        The folder should include the datacenter. ESX's datacenter is ha-datacenter
        
       
        Examples:
        
       
        folder: /ha-datacenter/vm
        
       
        folder: ha-datacenter/vm
        
       
        folder: /datacenter1/vm
        
       
        folder: datacenter1/vm
        
       
        folder: /datacenter1/vm/folder1
        
       
        folder: datacenter1/vm/folder1
        
       
        folder: /folder1/datacenter1/vm
        
       
        folder: folder1/datacenter1/vm
        
       
        folder: /folder1/datacenter1/vm/folder2
        
       
        folder: vm/folder2
        
       
        folder: folder2
         | 
     |
| hostname | 
      yes | 
        
        The hostname or IP address of the vSphere vCenter.
         | 
     ||
| password | 
      yes | 
        
        The password of the vSphere vCenter.
        
       
        aliases: pass, pwd
         | 
     ||
| username | 
      yes | 
        
        The username of the vSphere vCenter.
        
       
        aliases: user, admin
         | 
     ||
| validate_certs | 
      no | True | 
       
  | 
      
        
        Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.
         | 
     
| vm_id | 
      yes | 
        
        The identification for the VM
         | 
     ||
| vm_id_type | 
      no | vm_name | 
       
  | 
      
        
        The identification tag for the VM
         | 
     
| vm_password | 
      no | None | 
        
        The password used to login to the VM.
         | 
     |
| vm_shell | 
      yes | 
        
        The absolute path to the program to start. On Linux this is executed via bash.
         | 
     ||
| vm_shell_args | 
      no | None | 
        
        The argument to the program.
         | 
     |
| vm_shell_cwd | 
      no | None | 
        
        The current working directory of the application from which it will be run
         | 
     |
| vm_shell_env | 
      no | None | 
        
        Comma separated list of envirnoment variable, specified in the guest OS notation
         | 
     |
| vm_username | 
      no | None | 
        
        The user to connect to the VM.
         | 
     
Examples
- name: shell execution
  local_action:
    module: vmware_vm_shell
    hostname: myVSphere
    username: myUsername
    password: mySecret
    datacenter: myDatacenter
    folder: /vm
    vm_id: NameOfVM
    vm_username: root
    vm_password: superSecret
    vm_shell: /bin/echo
    vm_shell_args: " $var >> myFile "
    vm_shell_env:
      - "PATH=/bin"
      - "VAR=test"
    vm_shell_cwd: "/tmp"
  Notes
Note
- Tested on vSphere 5.5
 - Only the first match against vm_id is used, even if there are multiple matches
 
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/2.4/vmware_vm_shell_module.html