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

    Proper way to handle XO CloudConfigDrive and CloudInit post provisioning

    Scheduled Pinned Locked Moved Xen Orchestra
    cloudinitubuntu
    8 Posts 4 Posters 2.0k Views 4 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.
    • D Offline
      dkmuir
      last edited by

      Maybe it's a non-issue, but I was wondering what is the right way for dealing with the XO CloudConfigDrive after a VM has been provisioned? Do I just leave it there, or should it be removed from the VM?

      The other question I have relates to the cloud-init service. Should that be disabled after booting up?

      So for example, should something like the following config be used with a stock ubuntu cloud image from https://cloud-images.ubuntu.com ?:

      #cloud-config
      hostname: {name}%
      users:
        - default
      ssh_authorized_keys:
        - ssh-rsa ...
      package_update: true
      package_upgrade: true
      packages:
        - xe-guest-utilities
      byobu_by_default: system
      runcmd:
       - systemctl disable cloud-init
      power_state:
        delay: "+30"
        mode: poweroff
        message: Bye Bye
        timeout: 30
        condition: True
      

      And then remove the cloud config drive and then start the VM again, or can the disk be safely removed while the machine is running?

      fohdeeshaF 1 Reply Last reply Reply Quote 0
      • olivierlambertO Offline
        olivierlambert Vates 🪐 Co-Founder CEO
        last edited by

        fohdeesha will confirm but I think it's only loaded on boot, so I don't see any issue to remove it afterward 🤔

        D 1 Reply Last reply Reply Quote 0
        • D Offline
          dkmuir @olivierlambert
          last edited by

          olivierlambert Thanks!

          1 Reply Last reply Reply Quote 0
          • fohdeeshaF Offline
            fohdeesha Vates 🪐 Pro Support Team @dkmuir
            last edited by

            dkmuir when cloud-init is installed on a VM, it runs every single boot and searches for a config drive, mounts it, reads it, then unmounts it. If it sees it's the same as a previous config that's already been loaded (which is what will happen on a deployed VM after the firstboot), it'll ignore it and not do anything - it won't re-apply the same old config. So you can safely leave the old config drive there, however you can also safely remove the drive entirely as well - cloud-init will still scan on startup, but it won't find a config drive to even check. You can remove the config drive while the VM is running without issue, it's not even mounted any longer (cloud-init only temporarily mounts it during boot)

            You can also remove cloud-init iself indeed after the first boot

            D 1 Reply Last reply Reply Quote 0
            • D Offline
              dkmuir @fohdeesha
              last edited by

              fohdeesha Thanks for the thorough explanation. Took me a while to get the network configuration working, but I think I've got it all working nicely now from a stock Ubuntu cloud image.

              For those interested:

              My cloud init:

              #cloud-config
              hostname: {name}
              users:
                - default
              ssh_import_id:
                - gh:<username>
              package_update: true
              package_upgrade: true
              packages:
                - xe-guest-utilities
              byobu_by_default: system
              runcmd:
               - systemctl disable cloud-init
              power_state:
                delay: "+1"
                mode: reboot
                message: Rebooting system
                timeout: 5
                condition: True
              

              My network config:

              version: 2
              ethernets:
                eth0:
                  addresses: []
                  dhcp-identifier: mac
                  dhcp4: true
                  nameservers:
                    search:
                      - my.nameserver.local
              
              1 Reply Last reply Reply Quote 2
              • furyflash777F Offline
                furyflash777
                last edited by

                If delete CloudConfigDrive, then it will try to search configuration disk every time and break network config.
                You can just remove drive and create empty file /etc/cloud/cloud-init.disabled
                It will disable cloud-init.

                fohdeeshaF 1 Reply Last reply Reply Quote 0
                • olivierlambertO Offline
                  olivierlambert Vates 🪐 Co-Founder CEO
                  last edited by

                  Are you sure about that? On which distro with which config? I have no issue when I remove it on Debian here 🤔

                  1 Reply Last reply Reply Quote 0
                  • fohdeeshaF Offline
                    fohdeesha Vates 🪐 Pro Support Team @furyflash777
                    last edited by

                    furyflash777 I'm assuming you're on Ubuntu? Indeed as Olivier said this is tested on Debian and doesn't cause issues, but it seems on the newer Ubuntu versions with cloud-init, the new Netplan based network manager and how it interacts with cloud-init breaks/gets wiped if no cloud-init drive is found. Yet another cloud-init bug to track down

                    1 Reply Last reply Reply Quote 0
                    • E exu referenced this topic on
                    • First post
                      Last post