The vmware_guest_powerstate module

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" ...

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.