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

Power off a VM
# Power off
ansible-playbook /etc/ansible/playbooks/vm_power.yml -e "vm_name=ad01 power_state=powered-off"
Power on a VM
# Power on
ansible-playbook /etc/ansible/playbooks/vm_power.yml -e "vm_name=centos01 power_state=powered-on"
Graceful shutdown of a VM
# Graceful shutdown (guest tools needed)
ansible-playbook /etc/ansible/playbooks/vm_power.yml -e "vm_name=ad01 power_state=shutdown-guest"Restart of a VM
# Restart
ansible-playbook /etc/ansible/playbooks/vm_power.yml -e "vm_name=ad01 power_state=restarted"
Lets run the git and push it all

AWX → Projects → VMware Automation → Sync


