Instead of clicking around vCenter, we write a single Ansible playbook that handles any VM. AWX gives it a web form (called a survey) so anyone can run it without touching the command line.

Each playbook does one thing. No hardcoded VM names and everything comes in as a variable at runtime so we will add playbooks in this format.
playbooks/
├── get_all_vms.yml ← inventory
├── get_vm_info.yml ← VM details
├── vm_hardware.yml ← change RAM/CPU
├── vm_snapshot.yml ← snapshot management
├── vm_power.yml ← power on/off/restart
├── vm_deploy.yml ← deploy from template
├── vm_delete.yml ← delete VM
├── vm_network.yml ← change network
└── vm_disk.yml ← add/expand disk
Add a new playbook to Get vm_power.yml

Check the power state
# Check power state
ansible-playbook get_vm_info.yml -e vm_name=teller-app-01
Power off a VM
# Power off
ansible-playbook vm_power.yml -e vm_name=teller-app-01 -e power_state=powered-on

Shutdown on a VM
Check the power state first
# Power state check
ansible-playbook get_vm_info.yml -e vm_name=teller-app-01
Graceful shutdown of a VM
# Graceful shutdown (guest tools needed)
ansible-playbook /etc/ansible/playbooks/vm_power.yml -e vm_name=ad01 -e power_state=shutdown-guest
Restart of a VM
# Restart
ansible-playbook vm_power.yml -e vm_name=teller-app-01 -e power_state=restarted
Lets run the git and push it all

AWX → Projects → VMware Automation → Sync


