Introduction
Manual VM creation through Prism becomes inefficient at scale. Using acli, Nutanix’s AHV command-line interface, we can script VM deployment workflows that are reusable, fast, and fully automated. This guide shows how to build a Bash script that reads VM definitions from YAML and provisions them via acli.
My Personal Repository on GitHub
Architecture Overview

Step 1: Define Your VM Template in YAML
vms:
- name: web01
cpu: 2
memory: 4096
network: VLAN10
disk_size_gb: 40
- name: db01
cpu: 4
memory: 8192
network: VLAN20
disk_size_gb: 100
Save as vm_spec.yaml
Step 2: Bash Script to Parse YAML and Run acli
Requires yq (a lightweight YAML processor) and acli in the $PATH.
#!/usr/bin/env bash
set -euo pipefail
# Load and iterate through VM definitions
for i in $(yq e '.vms | keys | .[]' vm_spec.yaml); do
name=$(yq e ".vms[$i].name" vm_spec.yaml)
cpu=$(yq e ".vms[$i].cpu" vm_spec.yaml)
mem=$(yq e ".vms[$i].memory" vm_spec.yaml)
net=$(yq e ".vms[$i].network" vm_spec.yaml)
disk=$(yq e ".vms[$i].disk_size_gb" vm_spec.yaml)
echo "Creating VM: $name"
acli vm.create "$name" num_vcpus=$cpu memory=$mem
acli vm.disk.create "$name" create_size="${disk}G"
acli vm.nic.create "$name" network="$net"
acli vm.on "$name"
done
Step 3: Error Handling and Logging
Enhance reliability:
log="/var/log/nutanix_vm_deploy.log"
{
echo "[$(date)] Starting VM batch deploy"
# (insert main loop here)
echo "[$(date)] VM deploy complete"
} >> "$log" 2>&1
Optional: Add VM Tags for Metadata
acli vm.update "$name" custom_key_value="role:$role,env:$env"
Define tags in YAML and parse with yq the same way.
Summary
This method enables repeatable, scalable VM provisioning from structured input. Use YAML for clarity, acli for control, and Bash to orchestrate. Ideal for hybrid or edge environments needing consistent builds.
External Documentation Link:
Introduction Daily cluster health checks are a best practice for Nutanix administrators. While Prism offers visual insights, Bash scripting combined with ncli...