This section covers the power management of your virtual machine.
Use vcenter_vm_power_info
to know the power state of the VM.
- name: Get guest power information vmware.vmware_rest.vcenter_vm_power_info: vm: '{{ test_vm1_info.id }}' register: _result
{ "value": { "state": "POWERED_ON" }, "changed": false }
Use the vcenter_vm_power
module to start your VM:
- name: Turn the power of the VM on vmware.vmware_rest.vcenter_vm_power: state: start vm: '{{ test_vm1_info.id }}'
{ "changed": false }
If your virtual machine runs VMware Tools, you can build a loop around the center_vm_tools_info
module:
- name: Wait until my VM is ready vmware.vmware_rest.vcenter_vm_tools_info: vm: '{{ test_vm1_info.id }}' register: vm_tools_info until: - vm_tools_info is not failed - vm_tools_info.value.run_state == "RUNNING" retries: 60 delay: 5
{ "value": { "auto_update_supported": false, "upgrade_policy": "MANUAL", "install_attempt_count": 0, "version_status": "UNMANAGED", "version_number": 10346, "run_state": "RUNNING", "version": "10346", "install_type": "OPEN_VM_TOOLS" }, "changed": false }
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/scenario_guides/vmware_rest_scenarios/run_a_vm.html