-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path001.vm_power_control.yml
More file actions
34 lines (29 loc) · 939 Bytes
/
001.vm_power_control.yml
File metadata and controls
34 lines (29 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
- name: Control power state of a VM
hosts: localhost
gather_facts: false
connection: local
collections:
- community.vmware
vars:
vcenter_hostname: "192.168.1.3"
vcenter_username: "root"
vcenter_password: "#####"
datacenter_name: "Datacenter"
vm_name: "windows-master"
desired_state: "powered-on"
tasks:
- name: Power state management of a VM
vmware_guest_powerstate:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
datacenter: "{{ datacenter_name }}"
name: "{{ vm_name }}"
state: "{{ desired_state }}"
state_change_timeout: 120
delegate_to: localhost
register: result
- name: Show VM name and power state
debug:
msg: "VM '{{ result.instance.hw_name }}' is currently '{{ result.instance.hw_power_status }}'"