Ubuntu Template deployment via cloud-init Custom script | Nutanix Community
Skip to main content

Hi

  • I have a Ubuntu 20.04 LTS Installation on Nutanix AOS which serves as a template
  • This Ubuntu Tempate installation is a basic Ubuntu installation (clicked through basic installation, cloud-init installed)
  • Now i want users to be able to deploy a new VM as a clone from this Ubuntu template and passing via “Custom Script” option the cloud-init script in Prism GUI

Unfortunatly this does not work - the “Custom Script” cloud-init instructions are not applied during creation of the clone.

Do i possibly have to modify something inside the Ubuntu Template installation (ex. cloud-init datasource or similiar, /etc/cloud/cloud.cfg or whatever)?

Doesnt matter where i look the existing documentation (cloud-init, nutanix, ubuntu) etc. seems to be rather incomplete.

I had a working example in the past with Centos 7 deplyoment with Nutanix,cloud-init and deploying via Custom Script option in Prism element - but i cant get it running with Ubuntu

P.s
I’m aware of this article https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000CshJCAS - but this is not what i need - i dont want to give users who create vms access to acli -  they shall work only via Prism Element GUI in my environment hence i have to do it with the clone process of a Ubuntu template as described above.

 

hey @BGS , did you check out this post https://next.nutanix.com/community-blog-154/customizing-vms-with-cloud-init-on-nutanix-ahv-part-1-14573 , maybe this can help.

Otherwise, I think as you said you would possibly have to modify something inside the Ubuntu Template installation like cloud-init datasource or similiar, /etc/cloud/cloud.cfg etc. Give me some time I will research more on this and get back to you.


Thanks.

It’s an annoying thing. Seems to have to do with the Ubunut Cloud-init config. I have make a quick test with Centos 7 base install, install cloud-init and then cloning it in Prism via “Custom Script” option. This works out of the box.

I’ve made many tests with different cloud.cfg configurations with Ubuntu 20.04 - but no luck so far.

Under Ubuntu 20.04 you can easily change datasource from cloud-init via “dpkg-reconfigure cloud-init” and select “NoCloud” datasource..but that doesnt solve the problem.


Ok, i got it - it was a pain in the ass and i’m far away from having it finished for production but the part with Nutanix (Custom Script invokation in Clone Dialog) is solved.

Steps that are necessary for Ubuntu 20.04 LTS (*if* you have a Ubuntu 20.04 Basic Installation which you have set up normally as a Guest and which you want to use as a Source for Clones and adjustement via cloud-init) :

 

  1. apt purge cloud-init (clean up Template Installation from existing cloud-init)
  2. rm -rf /etc/cloud (clean up Template Installation from existing cloud-init)
  3. rm -rf /run/cloud-init (clean up Template Installation from existing cloud-init)
  4. apt install cloud-init (install cloud-init newly)
  5. dpkg-reconfigure cloud-init (select ConfigDrive, None as Options)
  6. systemctl enable cloud-init.service
  7. shutdown Template VM (and use it as Source VM for Clone in Prism)
  8. Clone the template VM via “Custom Script” option and pass your cloud-init user-data stuff

 

This is the basic outline. Maybe there would be an easier way - i hate cloud-init

 

 

 


Hey @BGS glad you could figure it way. Really happy. :sweat_smile:

 

BTW how did you figure it out.:smile: