This module is self-explanatory; it is used to manage the power stage of your VM. The following example power cycles a VM:
- name: Powercycle a vm
vmware_guest_powerstate:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
folder: "/vms"
name: "yet_another_example_vm"
state: "reboot-guest"
delegate_to: localhost
You can also schedule changes to the power state. The following example powers down the VM at 9 a.m. on the 1st April 2019:
- name: April fools
vmware_guest_powerstate:
hostname: "{{ vsphere_host }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: "no"
folder: "/vms"
name: "yet_another_example_vm"
state: "powered-off"
scheduled_at: "01/04/2019 09:00"
delegate_to: localhost
Not that I would ever do something like that!