Introduction
In production environments, VM provisioning requires more than just spinning up a virtual machine. You must ensure the VM is validated, tagged correctly, and monitored for failures. This enterprise-grade Ansible playbook combines provisioning, tagging, verification, and notifications in a single flow.
My Personal Repository on GitHub
Diagram: Full-Stack Enterprise Playbook Flow

Use Case
- Deploy complex VM sets with storage/network policies
- Validate provisioning status and alert on errors
- Apply metadata (env, owner, compliance) for policy compliance
- Integrate Slack for ops visibility
YAML File: enterprise_vm_config.yml
vms:
- name: analytics01
cpu: 4
memory: 16384
disk: 100
subnet: vlan20
tags:
- env:prod
- owner:analytics
- compliance:hipaa
- name: api01
cpu: 2
memory: 8192
disk: 50
subnet: vlan10
tags:
- env:prod
- owner:devops
Playbook: enterprise_vm_deploy.yml
- name: Enterprise Nutanix VM Provisioning
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
vars_files:
- nutanix_credentials.yml
- enterprise_vm_config.yml
vars:
slack_webhook: "https://hooks.slack.com/services/XXXX/YYYY/ZZZZ"
tasks:
- name: Deploy and tag VMs
loop: "{{ vms }}"
loop_control:
loop_var: vm
block:
- name: Create VM
nutanix.ncp.vms:
name: "{{ vm.name }}"
cluster_name: "prod-cluster"
state: present
power_state: poweron
memory_size_mib: "{{ vm.memory }}"
num_vcpus_per_socket: "{{ vm.cpu }}"
num_sockets: 1
vm_disks:
- disk_size_mib: "{{ vm.disk * 1024 }}"
storage_container: default-container
vm_nics:
- subnet_name: "{{ vm.subnet }}"
- name: Apply tags
loop: "{{ vm.tags }}"
loop_control:
loop_var: tag
nutanix.ncp.vms:
name: "{{ vm.name }}"
categories:
- name: "{{ tag.split(':')[0] }}"
value: "{{ tag.split(':')[1] }}"
state: update
cluster_name: "prod-cluster"
- name: Validate power state
nutanix.ncp.vms_info:
name: "{{ vm.name }}"
cluster_name: "prod-cluster"
register: vm_status
- name: Check VM health
assert:
that: "'on' in vm_status.vms[0].power_state"
fail_msg: "{{ vm.name }} is not powered on"
success_msg: "{{ vm.name }} passed health check"
rescue:
- name: Notify Slack of failed VM deploy
uri:
url: "{{ slack_webhook }}"
method: POST
headers:
Content-Type: application/json
body_format: json
body:
text: ":x: Nutanix VM {{ vm.name }} failed to deploy properly."
Output Example
TASK [Check VM health]
ok: [localhost] => {
"changed": false,
"msg": "analytics01 passed health check"
}
Run the Playbook
ansible-playbook enterprise_vm_deploy.yml --ask-vault-pass -i inventory.yml
Summary
This enterprise playbook goes far beyond basic VM creation. It tags, validates, and monitors the provisioning process, making it ideal for regulated environments or self-service portals backed by Git workflows.
External Documentation:
Introduction Enforcing configuration standards across Nutanix AHV VMs is critical for operational consistency and audit readiness. This article walks through an Ansible...