I have just installed the module Nutanix for Ansible. The demo playbook works fine.
But I can’t find in the module documentation how to deploy VM from a VM template just like we do with https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_module.html ?
This is not supported yet. You can file an improvement on the official GitHub repo.
In waiting, what would be the workaround ?
Is there a way through CLI ?
IMO, if using Ansible, Terraform, NCM Self-Service or any other infrastructure as code software, templates don’t make much sense. They are designed for GUI usage where you click many times and it’s time consuming and prone to mistakes.
When using Ansible, the playbook is your template, and your var files are the machine definitions. It’s kind to go against the principles of using IaC at the first place.
If I understand you well, you advice to code the VM deployment in playbook so that it starts from installation ISO, right ?
Not from ISO, but from the DISK image you already have and use to deploy your VMs from the GUI.
I’m relatively new to Nutanix. What I found efficient on VMware was to create VM templates from ISO with packer when necessary, and use these templates to deploy and configure VMs with Ansible, which is really fast.
I just tried to apply the same way on Nutanix, I just understand it’s not the good one.
I will have a look on DISK image and how use them to deploy VM through Ansible.
We have the same on Nutanix with AHV. You use Packer https://developer.hashicorp.com/packer/plugins/builders/nutanix/nutanix to create DISK images (OS image template). Then on your Ansible playbooks you consume that DISK image instead of an ISO (what Packer used to build the initial image).
It’s the same principle, just a different endpoint, AHV.
I followed your preconization and could deploy a new VM from a DISK image.
But how configure the hostname, and most important, the static IP while deploying ?
In VMWare ,when we deploy VMs with community.vmware.vmware_guest from a template, we just use network and customization parameter section in playbook to set hostname, IP/mask/gateway , DNS config. And the resulting VM has the proper IP and can immediately be configured by Ansible. Now idea how community.vmware.vmware_guest does that.
I guess I have to use cloud-init, right ?
That’s right. At the end of this example you have more details.
In addition, you can use ansible-doc nutanix.ncp.ntnx_vms_clone
I confirm that I succeeded to deploy with networking setting using “guest_customization:” and cloud-init templating below.
The only annoying thing is an extra delay in cloud-init steps (between init-locale and init processus) : around 2 minutes.
Any idea why ? Should I contact cloud-init community ?
Thx again for your help.
I’m not far from deployment maturity as I have reached with VMWare, making Nutanix a good candidate for the infra in our future factory.
I’m still confused : what is the real difference in the resulting VM between Disk image cloning method (with nutanix.ncp.ntnx_vms) and existing VM cloning (with nutanix.ncp.ntnx_vms_clone,for which I have still pb, see https://next.nutanix.com/ahv-virtualization-27/failed-to-clone-a-vm-with-ansible-41823) ?
Which method should be used in which cases ?
Related to cloud-init, that’s something you’ll have to investigate between the Linux distribution you are using and cloud-init documentation. That delay isn’t something related to AHV.
About difference between modules, nothing different to what you can do on the GUI.
At the end it comes up to what you prefer to follow that fits better on your operating model.
But im my case, as I generate Disk Image from an existing VM, it’s one more step than clone this existing VM directly to create a new VM, especially if customization (cloud-init/sysprep) can be applied in cloning process as well.
I’ll give a try of this.
Thank you a lot for your help.