Introduction

vm_power_map:
web01: poweron
db01: poweroff
test01: restart


Playbook: vm_power_control.yml

External Documentation:


Diagram: VM Power Workflow


Use Case

  • Gracefully power down VMs for patching
  • Restart development environments daily
  • Stop unused test VMs to save resources

Sample Variables: group_vars/all.yml

ansible-playbook vm_power_control.yml --ask-vault-pass -i inventory.yml


Optional Enhancements

  • Add tags to control groupings (e.g., stop all “test” VMs)
  • Validate state post-execution with register
  • Integrate with a schedule or CI job

Summary

Whether you’re scheduling routine maintenance, automating DR procedures, or managing lab environments, the ability to control VM power state is essential. With Ansible, you can automate VM power operations, start, stop, reboot, and validate, all from a single playbook.

Nutanix Repository on GitHub

Similar Posts