On this page
community.vmware.vmware_host_auto_start – Manage the auto power ON or OFF for vm on ESXi host
Note
This plugin is part of the community.vmware collection (version 1.15.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_host_auto_start.
Synopsis
- In this module, can set up automatic startup and shutdown of virtual machines according to host startup or shutdown.
 
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.7
 - PyVmomi
 
Parameters
| Parameter | Choices/Defaults | Comments | |
|---|---|---|---|
| esxi_hostname
        
        string / required
         | 
      
        
        ESXi hostname where the VM to set auto power on or off exists.
         | 
     ||
| hostname
        
        string
         | 
      
        
        The hostname or IP address of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_HOST will be used instead.
       
        Environment variable support added in Ansible 2.6.
         | 
     ||
| moid
        
        string
         | 
      
        
        Managed Object ID of the instance to manage if known, this is a unique identifier only within a single vCenter instance.
        
       
        This is required if  name or uuid is not supplied.
        | 
     ||
| name
        
        string
         | 
      
        
        VM name to set auto power on or off.
        
       
        This is not necessary if change only system default VM settings for autoStart config.
         | 
     ||
| password
        
        string
         | 
      
        
        The password of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_PASSWORD will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       aliases: pass, pwd  | 
     ||
| port
        
        integer
         | 
      Default: 
        443
         | 
      
        
        The port number of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_PORT will be used instead.
       
        Environment variable support added in Ansible 2.6.
         | 
     |
| power_info
        
        dictionary
         | 
      Default: 
        {"start_action": "none", "start_delay": -1, "start_order": -1, "stop_action": "systemDefault", "stop_delay": -1, "wait_for_heartbeat": "systemDefault"}
         | 
      
        
        Startup or shutdown settings of virtual machine.
        
       
        This setting will override the system defaults.
         | 
     |
| start_action
        
        string
         | 
      
       
  | 
      
        
        Whether to start the virtual machine when the host startup.
         | 
     |
| start_delay
        
        integer
         | 
      Default: 
        -1
         | 
      
        
        Auto start delay in seconds of virtual machine.
         | 
     |
| start_order
        
        integer
         | 
      Default: 
        -1
         | 
      
        
        The autostart priority of virtual machine.
        
       
        Virtual machines with a lower number are powered on first.
        
       
        On host shutdown, the virtual machines are shut down in reverse order, meaning those with a higher number are powered off first.
         | 
     |
| stop_action
        
        string
         | 
      
       
  | 
      
        
        Stop action executed on the virtual machine when the system stops of virtual machine.
         | 
     |
| stop_delay
        
        integer
         | 
      Default: 
        -1
         | 
      
        
        Auto stop delay in seconds of virtual machine.
         | 
     |
| wait_for_heartbeat
        
        string
         | 
      
       
  | 
      
        
        Continue power on processing when VMware Tools started.
         | 
     |
| proxy_host
        
        string
         | 
      
        
        Address of a proxy that will receive all HTTPS requests and relay them.
        
       
        The format is a hostname or a IP.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_PROXY_HOST will be used instead.
       
        This feature depends on a version of pyvmomi greater than v6.7.1.2018.12
         | 
     ||
| proxy_port
        
        integer
         | 
      
        
        Port of the HTTP proxy that will receive all HTTPS requests and relay them.
        
       
        If the value is not specified in the task, the value of environment variable  VMWARE_PROXY_PORT will be used instead.
        | 
     ||
| system_defaults
        
        dictionary
         | 
      
        
        System defaults for auto-start or auto-stop config for virtual machine.
         | 
     ||
| enabled
        
        boolean
         | 
      
       
  | 
      
        
        Enable automatically start or stop of virtual machines.
         | 
     |
| start_delay
        
        integer
         | 
      Default: 
        120
         | 
      
        
        Default auto start delay in seconds.
         | 
     |
| stop_action
        
        string
         | 
      
       
  | 
      
        
        Default stop action executed on the virtual machine when the system stops.
         | 
     |
| stop_delay
        
        integer
         | 
      Default: 
        120
         | 
      
        
        Default auto stop delay in seconds.
         | 
     |
| wait_for_heartbeat
        
        boolean
         | 
      
       
  | 
      
        
        Continue power on processing when VMware Tools started.
        
       
        If this parameter is enabled to powers on the next virtual machine without waiting for the delay to pass.
        
       
        However, the virtual machine must have VMware Tools installed.
         | 
     |
| use_instance_uuid
        
        boolean
         | 
      
       
  | 
      
        
        Whether to use the VMware instance UUID rather than the BIOS UUID.
         | 
     |
| username
        
        string
         | 
      
        
        The username of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_USER will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       aliases: admin, user  | 
     ||
| uuid
        
        string
         | 
      
        
        VM uuid to set auto power on or off, this is VMware's unique identifier.
        
       
        This is required if  
       name is not supplied.
       
        This is not necessary if change only system default VM settings for autoStart config.
         | 
     ||
| validate_certs
        
        boolean
         | 
      
       
  | 
      
        
        Allows connection when SSL certificates are not valid. Set to  
       false when certificates are not trusted.
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_VALIDATE_CERTS will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       
        If set to  true, please make sure Python >= 2.7.9 is installed on the given machine.
        | 
     |
Notes
Note
- All modules requires API write access and hence is not supported on a free ESXi license.
 
Examples
---
- name: Update for system defaults config.
  community.vmware.vmware_host_auto_start:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    esxi_hostname: "{{ esxi_hostname }}"
    system_defaults:
      enabled: true
      start_delay: 100
      stop_action: guestShutdown
- name: Update for powerInfo config of virtual machine.
  community.vmware.vmware_host_auto_start:
    hostname: "{{ hostname }}"
    username: "{{ username }}"
    password: "{{ password }}"
    esxi_hostname: "{{ esxi_hostname }}"
    name: "{{ vm_name }}"
    power_info:
      start_action: powerOn
      start_delay: 10
      start_order: 1
      stop_action: powerOff
      wait_for_heartbeat: true
  Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description | 
|---|---|---|
| power_info_config
        
        dictionary
         | 
      changed | 
        
        Parameter return when virtual machine power info config is changed.
         Sample:
        
       
        { "start_action": "powerOn", "start_delay": -1, "start_order": -1, "stop_action": "systemDefault", "stop_delay": -1, "wait_for_heartbeat": "systemDefault" }
         | 
     
| system_defaults_config
        
        dictionary
         | 
      changed | 
        
        Parameter return when system defaults config is changed.
         Sample:
        
       
        { "enabled": true, "start_delay": 120, "stop_action": "powerOff", "stop_delay": 120, "wait_for_heartbeat": false }
         | 
     
Authors
- sky-joker (@sky-joker)
 
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_host_auto_start_module.html