Ubuntu 24.04 Cloud Image Template Not Working
-
I don't see your users block in that config
Example:
users: ## Add users - name: user1 groups: sudo lock_passwd: false passwd: $6$xxxx....... ssh_authorized_keys: - ssh-ed25519 <my-key-ed25519>
So that may be an issue. See my examples for a guide.
-
Pretty sure you want the 'nocloud' data source as well. You can have cloud-init mount and install the xe guest tools if the virtual cd is attached at bootup.
-
You are using version 2 of your network config, did you happen to install netplanio package to consume your version 2 config, and is it enabled in the image you created? Otherwise, I have better luck with the version 1 network configs.
-
ok i got the cloud configs to work now and i can ssh in fine
one last thing i want to know is how do i add the guest tools to the cloud image?
did you mount the guest tools cdrom to the cloud image before you created a template from it?
can you share how you can add guest tools to the VM created from the cloud template at bootup?
thanks
here is cloud config that works
#cloud-config hostname: someotheruser ssh_authorized_keys: - ssh-rsa AAAAxxx - ssh-rsa AAAAxxx - ssh-ed25519 AAAAxxx
so how do i add installing guest tools?
when i tried to install via apt, here is what happened
https://xcp-ng.org/forum/topic/10088/how-to-install-guest-tools-via-apt -
Just add the commands to your cloud config in user-data;
runcmd: - mount /dev/cdrom /mnt - bash /mnt/Linux/install.sh - umount /dev/cdrom
-
just seeing your response now as i was trying to post new update
so i imported a new VM and made sure i mounted the guest-tools iso to it before converting it to template
i just tried this and it worked!!!
#cloud-config hostname: someotheruser ssh_authorized_keys: - ssh-rsa AAAAxxx - ssh-rsa AAAAxxx - ssh-ed25519 AAAAxxx runcmd: - [mkdir, -p, /mnt/guest-tools] - [mount, /dev/cdrom, /mnt/guest-tools] - [bash, /mnt/guest-tools/Linux/install.sh] - [umount, /dev/cdrom] - [rm, -rf, /mnt/guest-tools]
thanks for all your help, i think am good now!!!
-
@encryptblockr
Oh good! Glad you got it working.Keep in mind for those 'public' cloud images, (for anyone that uses them) you can have cloud-init install the xe guest utils at initialization as long as you have the guest-tools.iso mounted at bootup in the console within xo;
Sounds like you are getting the hang of it. Best of luck!
-
For reference, if you are testing network configs, here is a basic static ip v1 example I use to configure all distros, debian, ubuntu, RHEL, Rocky, Alma, Oracle linux, etc.
network: version: 1 config: - type: physical name: enX0 subnets: - type: static address: 192.168.0.xx/24 gateway: 192.168.0.1 - type: nameserver address: - 192.168.0.1 - 192.168.90.50 search: - example.tld
Works very well for me, as I am lazy and want to do as little manual configuration as possible, and XCP-ng and XO make that so easy. Most ENI, network-manager, systemd-networkd, netplan network stacks render this config fine. FYI
-
yeah was able to get ther networking working fine using the v1 also
thanks
am all good now, only other thing which am not really interested in as i prefer to create each VM one a time even if i need multiple
https://xcp-ng.org/forum/topic/10089/dynamic-cloudinit-network-config-feature-request
-
@encryptblockr said in Ubuntu 24.04 Cloud Image Template Not Working:
did you mount the guest tools cdrom to the cloud image before you created a template from it?
No, I just make my base images (for the end template) as generic as possible, and I do all mounts, package installs, accounts, keys, including the xe-guest utils package all in the user-data config for cloud-init. Makes the configurations more uniform across all stacks I have to maintain and scales really well with jinja templates.
also what is point of {name}% in below? can you explain? where does it get {name} from and what is % use?
That pulls the hostname from metadata that is provided by the nocloud datasource.
If you ever want to see all the metadata available (for example, say your provisioning plane does dynamic configuration from some backend IAS platform, and you need logic that renders metadata to run different configurations; run the following after login:
cloud-init query -a
For example, I run different configurations based on what the 'distro' value is -
example:cloud-init query -f {{v1.distro}}
{% if distro in ['rocky', 'ol', 'centos', 'fedora', 'redhat', 'almalinux'] -%} //do the rpm things//
This allows us to run completely different configuration settings based on what distro its being run in, or even what virtualization platform it is running on. Some platforms won't use the hostname, or fqdn meta values, so I have some if logic that only adds it when vendordata is null, example;
{% if vendordata == '' %} fqdn: {name} {% endif %}
Probably more than you wanted to know, but that's a brief summary of cloud-init metadata.