community.vmware.vmware_host_auto_start (4.2.0) — module

Manage the auto power ON or OFF for vm on ESXi host

Authors: sky-joker (@sky-joker)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

In this module, can set up automatic startup and shutdown of virtual machines according to host startup or shutdown.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
moid:
    description:
    - 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 O(name) or O(uuid) is not supplied.
    type: str

name:
    description:
    - VM name to set auto power on or off.
    - This is not necessary if change only system default VM settings for autoStart config.
    type: str

port:
    default: 443
    description:
    - The port number of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PORT)
      will be used instead.
    type: int

uuid:
    description:
    - VM uuid to set auto power on or off, this is VMware's unique identifier.
    - This is required if O(name) is not supplied.
    - This is not necessary if change only system default VM settings for autoStart config.
    type: str

hostname:
    description:
    - 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 E(VMWARE_HOST)
      will be used instead.
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PASSWORD)
      will be used instead.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_USER)
      will be used instead.
    type: str

power_info:
    default:
      start_action: none
      start_delay: -1
      start_order: -1
      stop_action: systemDefault
      stop_delay: -1
      wait_for_heartbeat: systemDefault
    description:
    - Startup or shutdown settings of virtual machine.
    - This setting will override the system defaults.
    suboptions:
      start_action:
        choices:
        - none
        - powerOn
        default: none
        description:
        - Whether to start the virtual machine when the host startup.
        type: str
      start_delay:
        default: -1
        description:
        - Auto start delay in seconds of virtual machine.
        type: int
      start_order:
        default: -1
        description:
        - 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.
        type: int
      stop_action:
        choices:
        - none
        - systemDefault
        - powerOff
        - suspend
        default: systemDefault
        description:
        - Stop action executed on the virtual machine when the system stops of virtual
          machine.
        type: str
      stop_delay:
        default: -1
        description:
        - Auto stop delay in seconds of virtual machine.
        type: int
      wait_for_heartbeat:
        choices:
        - 'no'
        - 'yes'
        - systemDefault
        default: systemDefault
        description:
        - Continue power on processing when VMware Tools started.
        type: str
    type: dict

proxy_host:
    description:
    - 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 E(VMWARE_PROXY_HOST)
      will be used instead.
    required: false
    type: str

proxy_port:
    description:
    - 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 E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

esxi_hostname:
    description:
    - ESXi hostname where the VM to set auto power on or off exists.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to V(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

system_defaults:
    description:
    - System defaults for auto-start or auto-stop config for virtual machine.
    suboptions:
      enabled:
        default: false
        description:
        - Enable automatically start or stop of virtual machines.
        type: bool
      start_delay:
        default: 120
        description:
        - Default auto start delay in seconds.
        type: int
      stop_action:
        choices:
        - none
        - guestShutdown
        - powerOff
        - suspend
        default: powerOff
        description:
        - Default stop action executed on the virtual machine when the system stops.
        type: str
      stop_delay:
        default: 120
        description:
        - Default auto stop delay in seconds.
        type: int
      wait_for_heartbeat:
        default: false
        description:
        - 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.
        type: bool
    type: dict

use_instance_uuid:
    default: false
    description:
    - Whether to use the VMware instance UUID rather than the BIOS UUID.
    type: bool

Outputs

power_info_config:
  description: Parameter return when virtual machine power info config is changed.
  returned: changed
  sample: "{\n  \"start_action\": \"powerOn\",\n  \"start_delay\": -1,\n  \"start_order\"\
    : -1,\n  \"stop_action\": \"systemDefault\",\n  \"stop_delay\": -1,\n  \"wait_for_heartbeat\"\
    : \"systemDefault\"\n}"
  type: dict
system_defaults_config:
  description: Parameter return when system defaults config is changed.
  returned: changed
  sample: "{\n  \"enabled\": true,\n  \"start_delay\": 120,\n  \"stop_action\": \"\
    powerOff\",\n  \"stop_delay\": 120,\n  \"wait_for_heartbeat\": false\n}"
  type: dict