Ansible Modules for Nutanix

  • 25 April 2019
  • 9 replies

Has anyone used Ansible for Automating Nutanix tasks. Can someone share some examples please.

9 replies

Userlevel 1
Badge +2

I'm using Ansible to configure prism settings. DNS, NTP, Alerts, proxy, authentication, and stuff like that. I will try to clean up all my specific data and publish them on the nutanix git, or my own git portal.
Hey @itguyadam - I am trying to list VMs on specific cluster using ansible - Currently, I am listing all the VMs and then filtering based on cluster_name.

Is there better way where I could pass cluster_name as filter and get VMs only on that particular cluster ?

Userlevel 1
Badge +2
@hfg_nutanix I've uploaded an ansible role to git. There are a few tasks i'm still working on and getting ready to publish but the bones of everything is there.
Userlevel 1
Badge +2
@OkBeacon What commands are you using currently?
@itguyadam - Thanks for reply!
I eventually figured out how to do it (Couldn't find any documentation about filters)

- import_tasks: get_session_cookie.yml

- name: Get VMS list
url: "{{ api_url_v3 }}/vms/list"
kind: vm
sort_order: ASCENDING
offset: 0
length: 1000
sort_attribute: ''
filter: "cluster_name=={{ cluster_name }}"
method: POST
validate_certs: no
body_format: json
status_code: 200
Cookie: "{{ session_cookie }}"

register: vms_result
Userlevel 1
Badge +2
@OkBeacon I've also found some of the API documentation a bit lacking in areas like that. I will most likely steal your task and use it in some other playbooks i'm working on. thanks
I am reusing code from

Currently working on provisioning k8s cluster on nutanix - I will put it on github once I am happy with it.
Userlevel 1
Badge +2

I’ve just created an ansible role ( for bulk creation of VMs using different images and in different subnets. It also mounts and enables NGT.



- Thanks for reply!
I eventually figured out how to do it (Couldn't find any documentation about filters)


The Filter specification was KILLING ME!    Thank you for sharing this.  It worked perfectly once I knew the context and syntax.