This series describes the installation, configuration and usage of the NTNX-AVM. In addition the mostly used scripts will be explained in detail.
full course- Nutanix automation VM ( NTNX-AVM ) goes online
- Unleash the power of the NTNX-AVM – daily_health_report and monthly_ncc_health
- Unleash the power of the NTNX-AVM – Import/Export/Migrate VMs to/from AHV
- Unleash the power of the NTNX-AVM – Move VM from one container to another container (AHV) with move_vm
Since I started at Nutanix I thought about a way to write and run scripts/tools around the Nutanix ecosystem. But there are different languages which are used by the community. Perl/python/golang/powershell etc. So I asked myself: “Where the hack should I install the runtime and the scripts/tools, because the CVM is a bad place for this”
The answer took me a while but here we go:
Nutanix automation VM called NTNX-AVM
So there is no image which fits all but instead the NTNX-AVM is based on recipes which defines the runtime/scripts/tools which will be installed. The foundation of these are the cloud images which are designed to run on cloud solutions like AWS/Azure/Openstack. These images provide good security from scratch. Another advantage is that the images are already deployed which means there is no different way to install it other then “importing” a vendor controlled image. This is good for maintaining the whole project.
NTNX-AVM v1 when deployed provides golang , git, govc, java, ncli (CE edition), vsphere CLI and the automation scripts from https://github.com/Tfindelkind/automation preinstalled. So for example you can move a VM from container A to container B with the move_vm binary which leverage the Nutanix REST API which is not possible in AHV.
I introduced a job scheduler system called https://github.com/dshearer/jobber to automate tasks/jobs. The advantages are that you are able to review the history of already executed jobs and you have more control when something went wrong.
Use cases for the NTNX-AVM
- Backup Nutanix VM’s to a NFS store like Synology/Qnap/linux…
- Move VM from one container to another one
- Do some daily tasks like generate reports of specific performance counters you would like to monitor which are not covered by Prism
- anything which talks to Nutanix REST API and needs to be scheduled.
- …. there will be more
Installation of NTNX-AVM on Acropolis Hypervisor (AHV)
For an easy deployment and usage I created a simple bash script which will do all the hard work.
The deployment for VMware and Hyper-V will follow. At the moment the process is more manual. I will post a “HOW-TO install”.
What you need is a Nutanix cluster based on AHV (>=4.7) and a client where you able to run the bash script. Ubuntu, Debian, Redhat, CentOS, Mac OS should work fine as a client. The Community Edition (CE) is the base of my development environment and is fully supported.
This is how the environment looks like before the deployment. My three node cluster based on Intel NUC.
Step-by-Step deployment of NTNX-AVM with Deploy Cloud Image script (DCI)
We start at your client system in my case a Mac Book Pro. Download the latest stable release of DCI from https://github.com/Tfindelkind/DCI/releases. In my case the version v1.0-stable is latest build available. The “Source code (tar.gz)” will work for me.
Change to the Download folder and unpack/untar the file:
1 2 |
cd Downloads tar -xvzf DCI-1.0-stable.tar.gz |
You can see there are several recipes available but let’s focus just on NTNX-AVM v1 based on CentOS7.
NTNX-AVM recipe config file
IMPORTANT: THE NTNX-AVM needs internet connection when deployed. Because all tools need to be downloaded.
Now we need to edit the recipe config file of the NTNX-AVM to make sure that the IP,DNS,etc. is setup in the way we need it. Use a text editor of your choice to edit the “/recipes/NTNX-AVM/v1/CentOS7/config” file.
You should edit following settings to your needs:
- VM-NAME This is the name of the VM guest OS.
- VM-IP The fixed IP
- VM-NET The network of VM
- VM-MASK The netmask of the network
- VM-BC The broadcast address of the network
- VM-GW The gateway
- VM-NS The nameserver
- VM-USER The username for the NTNX-AVM which will be created
- VM-PASSWORD The password for this user -> Support for access keys will be added soon.
- You need to escape some special characters like “/” with a “\” (Backslash)
- VCENTER_IP IP of the vcenter when used.
- VCENTER_USER User of the vcenter
- VCENTER_PASSWORD
This is an example file for my environment:
NTNX -AVM with DHCP enabled
If you don’t want to specify a fixed IP,DNS,.. you could roll out the NTNX-AVM with DHCP. To do this edit the “/recipes/NTNX-AVM/v1/CentOS7/meta-data.template” file and remove the network part so the file looks like this one. The “ifdown eth0” and “ifup eth0” is related to a bug with the CentOS 7 cloud-image.
1 2 3 4 5 |
instance-id: iid-VM-NAME bootcmd: - ifdown eth0 - ifup eth0 local-hostname: VM-NAME |
Deploy the NTNX-AVM to the Nutanix cluster
Now we are ready to deploy the VM to the Nutanix cluster with the dci.sh script.
We need to specify a few option to run it:
- –recipe=NTNX-AVM Use the pre build NTNX-AVM recipe
- –rv=v1 It’s the first version so we use v1
- –ros=CentOS7 In this case we use the CentOS7 image and not Ubuntu
- –host=192.168.178.130 This is the cluster IP of Nutanix/ CVM IP will work too
- –username/–password Prism user and password
- –vm-name The name of the Nutanix VM object
- –container=prod In my case I used the container “prod” (production)
- –vlan=VLAN0 The Nutanix network where the VM will be connected to
1 |
./dci.sh --recipe=NTNX-AVM --rv=v1 --ros=CentOS7 --host=192.168.178.130 --username=admin --password=nutanix/4u --vm-name=NTNX-AVM --container=prod --vlan=VLAN0 |
The dci.sh script will do the following:
- First it will download the cloud image from a CentOS. Then it will download the deploy_cloud_vm binary.
- It will read the recipe config file and generate a cloud seed CD/DVD image. Means all configuration like IP,DNS,.. will be saved into this CD/DVD image called “seed.iso”.
- DCI will upload the CentOS image and seed.iso to the AHV image service.
- The NTNX-AVM VM will be created based on the CentOS image and the seed.iso will be connected to the CD-ROM. At the first boot all settings will be applied. This is called the NoCloud deployment based on cloud-init. This will only work with cloud-init ready images.
- The NTNX-AVM will be powered on and all configs will be applied.
- In the background all tools/scripts will be installed
The CentOS cloud image and the seed.iso have been uploaded to the image service.
The NTNX-AVM has beed created and started.
Using the Nutanix Automation VM aka NTNX-AVM the first time
Connect via ssh to the NTNX-AVM IP. 192.168.178.200 in my case. First of all we need to make sure that all tools are fully installed because this is done in the background after the first boot.
So let’s check if /var/log/cloud-init-output.log will show something like:
The NTNX-AVM is finally up, after … seconds
You should reconnect via ssh once all tools/scripts are installed to make sure all environment variables will be set.
Everything is installed and we can use it.
Test the NTNX-AVM environment
Let’s connect to the Nutanix cluster with the “ncli” (nutanix command line) and show the cluster status.
1 2 3 4 |
ssh nutanix@192.168.178.200 ncli -s 192.168.178.130 -u admin -p nutanix/4u cluster status |
That’s it. NTNX-AVM is up running.
Today I start to implement the ntnx_backup tool which will be able to backup/restore a AHV VM to/from an external share (NFS, SMB,….) which will leverage jobber as the job scheduling engine.
Go Ubuntu