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 2.2k 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 @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