XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Ubuntu 24.04 Cloud Image Template Not Working

    Scheduled Pinned Locked Moved Xen Orchestra
    14 Posts 2 Posters 1.8k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      encryptblockr
      last edited by

      I have followed this guide https://xen-orchestra.com/blog/debian-cloud-template-for-xenserver/

      to create Ubuntu 24.04 cloud image template, all looks good from the guide and all even on Ubuntu 24.04 but when i create a VM from the template, the cloudinit is not working

      anyone been able to create cloud image template for Ubuntu 24.04 on XCP-ng?

      D 1 Reply Last reply Reply Quote 0
      • D Offline
        dj423 @encryptblockr
        last edited by

        @encryptblockr

        That guide may be a bit outdated. I would suggest following the guide I have posted over at https://xcp-ng.org/forum/topic/6821/cloud-init-success/3 for more recent noble/jammy cloud images.

        and if you can, use the cloud images provided by ubuntu/canonical as the base. Over here: https://cloud-images.ubuntu.com/noble/current/

        Can you provide any details on what didn't work? If you need to generate the base image from scratch, I can help but that is a bit more involved and challenging. Much better to go with the pre-canned cloud images when possible.

        E 2 Replies Last reply Reply Quote 0
        • E Offline
          encryptblockr @dj423
          last edited by

          @dj423

          i will try using the cloud images as base now

          what i used originally was the regular ISO here

          • https://isos.ubuntu.mirror.constant.com/24.04.1/

          and i used this one for 24.04 lts

          • https://isos.ubuntu.mirror.constant.com/24.04.1/ubuntu-24.04.1-live-server-amd64.iso

          i pretty much followed the guide i mentioned

          after i have the Ubuntu OS installed
          i made sure to use ubuntu as user

          i sshed in, sudo to root user and ran the following commands

          ubuntu@ubuntu:~$ sudo -i
          [sudo] password for ubuntu:
          root@ubuntu:~#
          root@ubuntu:~# mount /dev/cdrom /mnt
          root@ubuntu:~# bash /mnt/Linux/install.sh
          root@ubuntu:~# umount /dev/cdrom
          root@ubuntu:~# apt install -y cloud-init cloud-initramfs-growroot
          

          then went to /etc/cloud/cloud.cfg but i did not have anything to change as i am ok with the defaults

          then

          root@alien:~# dpkg-reconfigure cloud-init
          
          

          and made sure to only have the ConfigDrive checked

          dc2b16c7-52bd-46a2-8fab-e7d595cccd94-image.png ![1b65d665-e3c9-4214-858b-51d20192ffef-image.png](Input file contains unsupported image format)

          then ran this command next

          passwd -l root
          

          shut down the VM and converted to template

          and here are my cloud init settings when creating a VM from the template

          cloud config

          #cloud-config
          hostname: someotheruser
          ssh_authorized_keys:
            - ssh-rsa AAAAxxx
            - ssh-rsa AAAAxxx
            - ssh-ed25519 AAAAxxx
          

          network config

          network:
            version: 2
            ethernets:
              eth0:
                dhcp4: false
                #dhcp6: false
                addresses:
                  - 10.1.1.10/24
                  #- 4612:::/72
                gateway4: 10.1.1.1
                #gateway6: 4612:::0
                nameservers:
                  addresses:
                    - 1.1.1.1 
                    - 8.8.8.8
                    #- 2606:4700:4700::1111
                    #- 2001:4860:4860::8888
          

          What does not work?

          when i create a VM from the template, it does not create the user from my cloud config and nothing from my network config

          instead it boots up with original ip of the VM before i create d a template form it, meaning it does not work

          D 1 Reply Last reply Reply Quote 0
          • E Offline
            encryptblockr @dj423
            last edited by

            @dj423

            one issue with the cloud images is that one cant setup the guestools on them baked into the image

            that is issue

            so every VM i create i have to install the guest tools on all of them

            all good though since its pretty quick setup but would be great to have them install at bootstrap

            or cna one install it with the cloud config? that might be possible actually but never tried that

            D 2 Replies Last reply Reply Quote 0
            • D Offline
              dj423 @encryptblockr
              last edited by dj423

              @encryptblockr

              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.

              1 Reply Last reply Reply Quote 0
              • D Offline
                dj423 @encryptblockr
                last edited by

                @encryptblockr

                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.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dj423 @encryptblockr
                  last edited by

                  @encryptblockr

                  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.

                  E 1 Reply Last reply Reply Quote 0
                  • E Offline
                    encryptblockr @dj423
                    last edited by encryptblockr

                    @dj423

                    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

                    D 2 Replies Last reply Reply Quote 0
                    • D Offline
                      dj423 @encryptblockr
                      last edited by dj423

                      @encryptblockr

                      Just add the commands to your cloud config in user-data;

                      runcmd:
                        - mount /dev/cdrom /mnt
                        - bash /mnt/Linux/install.sh
                        - umount /dev/cdrom
                      
                      
                      E 1 Reply Last reply Reply Quote 1
                      • E Offline
                        encryptblockr @dj423
                        last edited by

                        @dj423

                        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!!!

                        D 2 Replies Last reply Reply Quote 0
                        • D Offline
                          dj423 @encryptblockr
                          last edited by

                          @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;

                          d6feb452-ed0f-4e96-a990-d4d979d926a0-image.png

                          Sounds like you are getting the hang of it. Best of luck!

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            dj423 @encryptblockr
                            last edited by

                            @encryptblockr

                            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

                            E 1 Reply Last reply Reply Quote 0
                            • E Offline
                              encryptblockr @dj423
                              last edited by

                              @dj423

                              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

                              1 Reply Last reply Reply Quote 1
                              • D Offline
                                dj423 @encryptblockr
                                last edited by

                                @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.

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post