community.vmware.vmware_guest_powerstate – Manages power states of virtual machines in vCenter¶
Note
This plugin is part of the community.vmware collection (version 1.9.0).
To install it use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_guest_powerstate
.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
PyVmomi
Parameters¶
Examples¶
- name: Set the state of a virtual machine to poweroff
community.vmware.vmware_guest_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ datacenter_name }}/vm/my_folder"
name: "{{ guest_name }}"
state: powered-off
delegate_to: localhost
register: deploy
- name: Set the state of a virtual machine to poweron using MoID
community.vmware.vmware_guest_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ datacenter_name }}/vm/my_folder"
moid: vm-42
state: powered-on
delegate_to: localhost
register: deploy
- name: Set the state of a virtual machine to poweroff at given scheduled time
community.vmware.vmware_guest_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ datacenter_name }}/vm/my_folder"
name: "{{ guest_name }}"
state: powered-off
scheduled_at: "09/01/2018 10:18"
schedule_task_name: "task_00001"
schedule_task_description: "Sample task to poweroff VM"
schedule_task_enabled: True
delegate_to: localhost
register: deploy_at_schedule_datetime
- name: Wait for the virtual machine to shutdown
community.vmware.vmware_guest_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
name: "{{ guest_name }}"
state: shutdown-guest
state_change_timeout: 200
delegate_to: localhost
register: deploy
Authors¶
Abhijeet Kasurde (@Akasurde) <akasurde@redhat.com>