Ansible on Nutanix AHV Automation Complete Guide
By Luca Berton · Published 2024-01-01 · Category: security-compliance
Automate Nutanix AHV with Ansible: nutanix.ncp collection, Prism Central v3/v4 APIs, VMs, categories, projects, NCM Self-Service (Calm) blueprints.
Nutanix AHV is the native KVM-based hypervisor in the Nutanix Cloud Platform (NCI). It's managed through Prism Central (multi-cluster) and Prism Element (per-cluster). Ansible automates AHV via the official nutanix.ncp collection, which targets Prism Central v3 and v4 APIs and covers VMs, categories, projects, images, subnets, and NCM Self-Service (formerly Calm) blueprints. This is the master Ansible guide for Nutanix AHV.
Nutanix release facts
| Item | Value | |---|---| | Hypervisor | AHV (KVM-based) | | Management | Prism Central (multi-cluster), Prism Element (per-cluster) | | APIs | v3 (mature), v4 (modern, OpenAPI) | | Ecosystem | NCM Self-Service (Calm), Flow Networking, Files, Objects |
See also: Ansible AWS: Complete Guide to Cloud Automation (2026)
Ansible-core compatibility
Use ansible-core 2.18 LTS:
collections:
- name: nutanix.ncp
version: ">=2.0.0"
Inventory / connection vars
# group_vars/nutanix.yml
nutanix_host: pc.lab.example.com
nutanix_username: admin
nutanix_password: "{{ vault_nutanix_password }}"
nutanix_port: 9440
validate_certs: false
See also: Ansible Become: Privilege Escalation with sudo, su & runas (Complete Guide)
Create a VM
- name: Create AHV VM via Prism Central
hosts: localhost
gather_facts: false
tasks:
- name: Provision VM
nutanix.ncp.ntnx_vms:
nutanix_host: "{{ nutanix_host }}"
nutanix_username: "{{ nutanix_username }}"
nutanix_password: "{{ nutanix_password }}"
validate_certs: false
state: present
name: app-01
cluster:
name: PROD-CLUSTER
memory_gb: 8
vcpus: 4
cores_per_vcpu: 1
networks:
- is_connected: true
subnet:
name: vlan100
disks:
- type: DISK
size_gb: 80
bus: SCSI
boot_config:
boot_type: UEFI
boot_order:
- DISK
- CDROM
- NETWORK
guest_customization:
type: cloud_init
script_path: ./cloud-init/app-01.yaml
Categories and projects
- name: Tag VM with categories
hosts: localhost
gather_facts: false
tasks:
- name: Apply categories
nutanix.ncp.ntnx_vms:
nutanix_host: "{{ nutanix_host }}"
nutanix_username: "{{ nutanix_username }}"
nutanix_password: "{{ nutanix_password }}"
validate_certs: false
state: present
name: app-01
categories:
Environment:
- Production
AppType:
- Web
See also: Ansible check_mode: Dry Run & Test Playbooks Without Making Changes
Image upload
- name: Upload image to Prism Central
hosts: localhost
gather_facts: false
tasks:
- name: Upload Ubuntu 24.04 cloud image
nutanix.ncp.ntnx_images:
nutanix_host: "{{ nutanix_host }}"
nutanix_username: "{{ nutanix_username }}"
nutanix_password: "{{ nutanix_password }}"
validate_certs: false
state: present
name: ubuntu-24.04-server-cloudimg
image_type: DISK_IMAGE
source_uri: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
clusters:
- name: PROD-CLUSTER
Run a Calm blueprint
- name: Launch a NCM Self-Service blueprint
hosts: localhost
gather_facts: false
tasks:
- name: Launch blueprint
nutanix.ncp.ntnx_blueprints:
nutanix_host: "{{ nutanix_host }}"
nutanix_username: "{{ nutanix_username }}"
nutanix_password: "{{ nutanix_password }}"
validate_certs: false
state: present
name: bp-three-tier-web
project:
name: WebApps
Best practices
• Manage Nutanix at the Prism Central layer, never per-Prism Element, for multi-cluster consistency. • Tag everything with categories; use them in Flow security policies and Self-Service entitlements. • Use API keys / service accounts with role-based access; avoidadmin.
• Pin to v4 API where supported; fall back to v3 for older modules. The collection abstracts this transparently.
Conclusion
Nutanix AHV + nutanix.ncp provides a clean Ansible interface for the entire Nutanix Cloud Platform — VMs, networking, images, categories, projects, and Self-Service blueprints. Standardize on Prism Central, categories, and version-pinned blueprints to manage Nutanix HCI at scale.
Category: security-compliance