Ubuntu 20.04 Autoinstall - using Cloud-Init Custom Script | Nutanix Community
Skip to main content

So - I have been trying to get some sort of automation of my Ubuntu VM creation in Prism, either by setting up a template machine that I would later modify using cloud-init custom scripts, or even better using a custom cloud-init script at creation to run through the “Ubuntu autoinstall” 

 

I have tried a few times now to install an Ubuntu server by clicking my way through the GUI and then using the resulting .yml file to try and install a VM from scratch…

 

Using “clone” from a template I can use a custom script to change hostname and so forth, but still having some problems changing the network settings (saying they are disabled by system.cfg). I guess I will be able to figure that part out eventually, but my main goal is to be able to register a new machine in Netbox, and from the info I have entered there automatically create a cloud-init fileand use that to trigger VM creation in Nutanix… 

 

When I try to create a new VM - mounted with the Ubuntu 20.04.4 installer ISO and a 100GB disk - and then paste my “autoinstall information” into the Custom Script area - it doesn’t get picked up for some reason. Why not? (I also have different versions trying to do storage modifications, but since basically nothing happens with this fairly simple config, I doubt it will be much better with the full file…. ) Do I HAVE to use a template or a cloud image? 

Is it just a matter of Nutanix not understanding the “autoinstall” keyword, or is it an error in the yaml-file, or is this type of installation just not supported? 

 

#cloud-config
autoinstall:
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: ramd64, i386]
uri: http://some.internal.repo/ubuntu
- arches: rdefault]
uri: http://some.internal.repo/ubuntu
identity: {hostname: my-hostname-n01, password: "SomeLongAndCryptedPassword",
realname: My Name, username: memyselfandi}
keyboard: {layout: 'no', toggle: null, variant: ''}
locale: en_US
network:
ethernets:
ens3:
addresses: 192.168.10.15/24]
gateway4: 192.168.10.1
nameservers:
addresses: e192.168.10.11, 192.168.10.12, 192.168.10.13, 192.168.10.14]
search: 2one.domain, two.domain, three.domain]
version: 2
ssh:
allow-pw: true
authorized-keys: -]
install-server: true
version: 1

 

Update: 

I pasted the data from the cloud-init above into a file called user-data, created an empty meta-data file and created an iso image called test_seed.iso containing those 2 files… 

 

Created a vm using the ubuntu-20.04.2-live ISO as a CDROM, the test_seed.iso mounted as a disc and then a 100GB disk, and then it seems the autoinstaller runs correctly using the defaults where I haven’t specified anything… (except I had to answer “yes” to the autoinstall) 

 

When Nutanix reads the custom scripts it mounts it as an ISO, but autoinstall does not work - while this method which basically does “the same thing” does? Not sure what kind of conversion Nutanix performs on the cloud-init file when creating the “CD-ROM” iso - but would really love for this to work out of the box. 


I can tell you that the cloud-config script portion works if you are using an Ubuntu “Cloud Image” (which is different from a normal ISO install).

The Cloud image starts with a basic “installed” disk image, which you have to clone into a new VM (and it applies the settings from the script during the first boot of that VM). Your cloud-image script can install a slew of packages for you during the setup, so there’s generally not any need to start from a customized “base” unless you’re trying to do something extra fancy that can’t be handled in the cloud-init script.

I’ve never tried doing an auto-config script from a standard ISO install…

When downloading the cloud image, make sure you grab the correct version. Even though Nutanix is technically KVM at its core, you do not want the KVM flavor of cloud image!


As an example, for Ubuntu 20.04 - (http://cloud-images.ubuntu.com/releases/focal/release/) 
 ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img   - doesn’t work
 ubuntu-20.04-server-cloudimg-amd64.img   - this is what you want

There’s a KB article explaining that you might have to add a serial port to the VM before first boot; IIRC this has been fixed in newer releases of the cloud image (or newer releases of AOS/AHV), because I don’t remember having to go through this mess on recent deployments.