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

    Create a Ubuntu 18.04 cloud init template

    Scheduled Pinned Locked Moved Xen Orchestra
    18 Posts 4 Posters 3.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.
    • olivierlambertO Offline
      olivierlambert Vates 🪐 Co-Founder CEO
      last edited by

      No need, we'll have tested templates available for everyone for our next XOA release, within "XO hub" feature 🙂

      1 Reply Last reply Reply Quote 0
      • bcatubigB Offline
        bcatubig
        last edited by

        For those trying to create an Ubuntu 18.04 cloud-init template and are stuck wondering why SSH does not work or why the vm disk size is not matching up to what was configured in XOA, please follow the below extra steps.

        Note: If using the Ubuntu 18.04 in XCP-NG Center (not XOA), the mininum disk size is 10GB (it is not configurable to 4GB as described in the original Debian article.)

        IMO, ignore the CloudInit part of @olivierlambert original blog post (debian) and follow the below steps

        The following commands need to be run after you have installed Ubuntu 18.04 (but before you have converted the vm to a template)

        # install cloud-init and deps
        sudo apt install cloud-init cloud-initramfs-growroot
        
        # !!! This part is important, make sure to keep ConfigDrive checked !!!
        # remove all datasources except `ConfigDrive: Reads data from Openstack Config Drive`
        sudo dpkg-reconfigure cloud-init
        
        # enable cloud-init systemd unit
        sudo systemctl enable cloud-init
        
        # disables bug message from https://bugs.launchpad.net/bugs/1669675
        touch /home/ubuntu/.cloud-warnings.skip
        
        # disable root password
        passwd -l root
        

        and finally, power off the vm and convert to a template.

        Notes

        • You shouldn't have to configure the default /etc/cloud/cloud.cfg file as it comes configured by Ubuntu out of the box
        • The key is to enable the cloud-init systemd unit before powering off the vm.
        • Before enabling cloud-init, when a vm launched from the original template, it did not have SSH installed or the correct disk size.
        M 2 Replies Last reply Reply Quote 1
        • M Offline
          moisei @bcatubig
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • M Offline
            moisei @bcatubig
            last edited by

            @bcatubig I've done all the magic but still my cloud init is not taken into account completely.
            I can see the VM is created with 10 MB additional disk.
            I can mount this device and see that it does contain my cloud-init script.
            but the script is not executed and cloud-config logs don't contain any useful information.
            Please advise what would be the right way to track this issue??

            bcatubigB 1 Reply Last reply Reply Quote 0
            • bcatubigB Offline
              bcatubig @moisei
              last edited by

              @moisei Can you list steps taken?

              Can you verify that ConfigDrive is enabled in the dpkg-reconfigure of cloud-init?

              I haven't experimented with a full cloud-config. Only injecting an SSH key via XOA. I'll run through the steps again tonight to see if I run into any issues.

              M 1 Reply Last reply Reply Quote 0
              • M Offline
                moisei @bcatubig
                last edited by

                @bcatubig yes ConfigDrive and only ConfigDrive is enabled. My script does 3 things: SSH, set hostname, and touch some file. None of them is executed and the cloud-init logs doesn't show any trace of the execution.

                #cloud-init
                
                hostname: {name}%
                
                ssh_authorized_keys:
                  - ssh-rsa AAAA...kd mykey@myhost
                
                runcmd:
                 - [ touch, "/tmp/CLOUD_INIT_WAS_HERE", / ]
                 - touch /tmp/CLOUD_INIT_WAS_HERE_1
                 - touch "/tmp/CLOUD_INIT_WAS_HERE_2"
                
                bcatubigB 1 Reply Last reply Reply Quote 0
                • bcatubigB Offline
                  bcatubig @moisei
                  last edited by

                  @moisei Before rebooting the Ubuntu 18.04 vm to convert it to an image, did you enable cloud-init service by running

                  sudo systemctl enable cloud-init
                  

                  before powering off the vm?

                  M 1 Reply Last reply Reply Quote 0
                  • M Offline
                    moisei @bcatubig
                    last edited by

                    @bcatubig yes I did. I've just followed your instructions above. Also the fact the cloud-init logs are present indicates that it is running, isn't it?

                    bcatubigB 1 Reply Last reply Reply Quote 0
                    • bcatubigB Offline
                      bcatubig @moisei
                      last edited by

                      @moisei Sure

                      Can you try running dpkg-reconfigure cloud-init and select both ConfigDrive and the Openstack option.

                      From there, I would try the vm template process again.

                      If that still fails, I would try manually invoking cloud-config from the new vm with the attached cloud-config drive to see if there is an issue with cloud-config or your config.

                      It should provision itself automatically if everything is correct.

                      If that fails, you may need to attempt the entire process again and do some more trial/error.

                      M 1 Reply Last reply Reply Quote 0
                      • M Offline
                        moisei @bcatubig
                        last edited by

                        @bcatubig it didn't help. would you mind to share the config that is working for you?

                        bcatubigB 1 Reply Last reply Reply Quote 0
                        • bcatubigB Offline
                          bcatubig @moisei
                          last edited by

                          @moisei I didn't use a custom cloud config. I've only tried adding the ssh-key via XOA

                          M 1 Reply Last reply Reply Quote 0
                          • M Offline
                            moisei @bcatubig
                            last edited by

                            @bcatubig 776ddfa2-a97c-4ea6-adb5-2dd05943b421-image.png

                            I see this message on the console right after the VM is created. Could it be somehow helpful?

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