Centos VM Creation on Nutanix Using Ansible


Nutanix Prism is an end-to-end consumer-grade management solution for virtualized datacenter environments. Prism manages the entire stack from the storage and compute infrastructure all the way up to virtual machines (VMs).

Here, we’ll discuss how to create a CentOS VM on Nutanix using Ansible playbook. Ansible is a high-level automation engine that automates cloud provisioning, configuration management, application deployment.


  • Nutanix Prism login credentials
  • Nutanix cluster URL, cluster name, subnet name and disk image name


Ansible roles are sets of Ansible defaults, files, tasks, templates, variables, and other Ansible components that work together. ‘nutanix_vm_provisioner’ is a basic Ansible role to provision VMs on a Nutanix AHV using APIv3.

Required variables:

  • api_version:                 # add API version, it’s best to use v3, if available
  • cluster_url:                   # IP address where you would normally log into PRISM
  • prism_user:                  # An account with permissions to provision on the cluster
  • prism_password:        # The password to your account
  • cluster_name:             # Name of the cluster to provision against
  • subnet_name:             # Name of the Subnet to add VMs to
  • image_name:              # Name of the disk image or ISO to use
  • vm_defs:                      # The list of dicts that define the VMs to be created

A single role ‘nutanix_vm’ is required for the VM creation.

nutanix_vm’ role deals with the creation of a VM with the provided subnet, cluster and the OS image by authenticating with a session cookie for logging into the prism. The required variables are to be placed in ‘defaults’ folder. ‘tasks’ for the role is shown step-by-step in the next page.


(nutanix_vm): shows how the authentication to the prism is done by creating a session cookie.

Copy to Clipboard


(nutanix_vm):  shows how to get the cluster lists and uuids to use.

Copy to Clipboard


(nutanix_vm):  shows how to get the subnet lists and uuids to use.

Copy to Clipboard


(nutanix_vm):  shows how to get the images list and the uuids to use.

Copy to Clipboard


(nutanix_vm):  shows how to define and use the uuids for the VM creation.

Copy to Clipboard


(nutanix_vm): shows how to provision a new VM (uses CentOS image here).

Copy to Clipboard

‘nutanix.py’ is a Python script which generates an inventory that Ansible can understand by making API requests to one or more Nutanix clusters. This is placed in the templates folder. You can get a clear idea on this by referring https://github.com/mattkeeler/ansible-nutanix-inventory


(nutanix_vm): template ‘nutanix.yml.j2’ is given below.

Copy to Clipboard


Ansible is a simple and efficient tool for automating infrastructure (IaC – Infrastructure as Code). In this tutorial, I used Ansible role nutanix_vm_provisioner’ for the creation of CentOS VM on Nutanix. Ansible can also help in tasks like app deployments, configuration management and wokflow orchestration.


  • https:// galaxy.ansible.com/mbach04/nutanix_vm_provisioner
  • https://github.com/mattkeeler/ansible-nutanix-inventory

About The Author

Sreedevi J S

Cloud Dev-Ops Engineer | Cloud Control

Cloud DevOps Engineer with more than three years of experience in supporting, automating, and optimizing deployments to hybrid cloud platforms using DevOps processes, tools, CI/CD, containers and Kubernetes in both Production and Development environments.