Cloud Config success
-
While I was waiting on a fix for the OVA import issues I was experiencing, I decided to work on a solution myself to getting a template I could use Cloud Configs on.
Through much trial and error, I managed to figure out a build template that works for Ubuntu 22.04 LTS that gets you a base image that will recognize standard Cloud Configs in XOCE and apply them successfully. I thought I'd write it up for anyone else who may be banging their heads against the wall like I was.
***Note: almost ALL of this was knowledge gleaned from other users in other posts, comments and various forum posts here and on other websites. All I did was figure out what worked, in a repeatable fashion, so I could actually use the configs as intended.
How I built my cloud disk and used Cloud Config ;
-
Installed Ubuntu 22.04 LTS as VM, (I used 2 cpu, 8G ram, 10G drive)
-
Upon reboot, I updated/upgraded w/apt
-
Installed Guest Tools
-
Ran sudo apt install cloud-initramfs-growroot
- (an absolute MUST if you want your VM to apply a Cloud Config...took me 4 or 5 times reinstalling and trying various things not realizing how important this was for success. I thought it was automatically installed with the Cloud-Init package.....it is not).
-
Ran sudo cloud-init clean
-
Ran sudo truncate -s 0 /etc/machine-id /var/lib/dbus/machine-id
- Used to clear out machine-id for regeneration. Found that if you deleted the file, it would not be regenerated during the reboot but if you zeroed it out, it would.
Shutdown VM and created a template from that image.
Doing this allowed me to apply Cloud Configs and have them actually stick to any new VM created from that image.
One thing...the configs MUST be in perfect YAML format so running through a verifier helps spot issues. I was missing a space between the hashed_passwd: colon and the start of the password. It took a verifier to point that out.
Hopefully this helps someone in the future
-
-
-
This post saved me a lot of time. Thank you for sharing
-
@ManonMercier if you volunteer, it might worth a guide/doc somewhere as a reference
-
Noted @olivierlambert. Posting back here when it's done.
-
Dear @fataugie,
Thank you for sharing your findings! We have added the method you described to our documentation -
I am now a VMware -> XCP-ng convert and wish I had known sooner. This post helped me get to the point of fully automated template and server builds with Packer/Terraform.
Here are my code samples. Hope it helps someone else!
Packer/XCP-ng Templates
https://github.com/mtcoffee/xcp-ng-packer-examplesTerraform/XCP-ng Templates
https://github.com/mtcoffee/xcp-ng-terraform-examples