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

    Ubuntu 18.04 Cloud-Init Networking Problem

    Scheduled Pinned Locked Moved Xen Orchestra
    13 Posts 3 Posters 4.5k Views 3 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.
    • S Offline
      slynch @slynch
      last edited by

      Well I never figured out how to create this from scratch, but I did get it working.

      I took the VM that was created from the original template (with the networking that wouldn't come up) and changed /var/lib/cloud/instance/datasource from

      DataSourceNoCloud: DataSourceNoCloud [seed=/dev/xvdb][dsmode=net]
      

      to

      DataSourceNoCloud: DataSourceNoCloud [seed=/dev/xvdb][dsmode=local]
      

      Then since this VM had already done it's first boot, I needed to run cloud-init clean to remove the cache.

      👍

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        slynch @slynch
        last edited by

        Nevermind. I thought I had it, but it was a false positive because I had an old networking config laying around in /etc/netplan that was providing the networking. It wasn't actually getting the networking from cloud-init running on first boot.

        From what I can gather, I need to add dsmode: local to the metadata that is given to cloud-init. How do I do that from XO? Does that need to be added to the XO CloudConfigDrive?

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

          @slynch Indeed this needs to be passed in the meta-data file, and there's currently no way in XOA in the GUI to pass anything into this file. This thread has some more info and sums up my feelings on cloud-inits documentation state: https://gist.github.com/Informatic/0b6b24374b54d09c77b9d25595cdbd47

          We do write out a meta-data file, but as of now there's no way to pass custom contents into it, it is just used to pass the VM UUID into cloud-init: https://github.com/vatesfr/xen-orchestra/blob/master/packages/xo-server/src/xapi/index.js#L2019

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            slynch @fohdeesha
            last edited by

            @fohdeesha I did see that gist. And I also found that part in code in XO that sets the metadata for the config drive. Would it be possible to put in another metadata line in addition to the instance-id to specify the dsmode?

            1 Reply Last reply Reply Quote 0
            • S Offline
              slynch
              last edited by

              I made the change in
              https://github.com/lynchs61/xen-orchestra/blob/16ad1ad41f48230f6c27ef0e6c2a73ea7884d794/packages/xo-server/src/xapi/index.js#L2026

              And I confirmed with my XO that it does in fact work to populate the metadata and set the NoCloud datasource mode to local. But unfortunately it still never runs netplan apply after it runs netplan generate. If I go into the VM after creation and run netplan apply everything is fine but it won't run it during the first boot.

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

                @slynch that end of the issue sounds like a cloud-init bug/issue, which doesn't surprise me (I've been fighting with them since I started here at Vates). I suppose you could manually work around it, somewhere in the cloud-init options/parameters is optional commands to pass and run in the VM on first run, I suppose you could pass "netplan apply" there.

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  slynch @fohdeesha
                  last edited by

                  I was able to get this working!

                  I had read that it's important to delete anything existing in /etc/netplan otherwise it won't be overwritten by the new networking setup. But, first of all, that's not true in my case. And second, when there's nothing existing in that directory to start with, cloud-init doesn't run netplan apply for the new network setup (not sure why this is but I guess it's just a bug). So I just left the default Netplan DHCP setup in the template and now it works.

                  I'd be happy to give this to others to test, and then if it looks good, contribute it to the Hub. If anyone is interested let me know a place to upload the template.

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

                    @slynch Interesting! since you left the default DHCP netplan, does the VM also have a DHCP config and grab a DHCP address in addition to your cloud-init config?

                    Also, you mean when there is netplan content, cloud-init does finally apply netplan apply like it's supposed to? interesting

                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      slynch @fohdeesha
                      last edited by

                      @fohdeesha The VM has both of the netplan configurations in /etc/netplan - the original DHCP and CloudInit config.

                      > ls -la /etc/netplan/
                      total 16
                      drwxr-xr-x   2 root root 4096 Apr 15 12:44 .
                      drwxr-xr-x 104 root root 4096 Apr 15 17:59 ..
                      -rw-r--r--   1 root root  193 Apr  9 16:27 01-netcfg.yaml
                      -rw-r--r--   1 root root  648 Apr 15 12:44 50-cloud-init.yaml
                      

                      But the DHCP address is replaced by the new config. So yes, it successfully reads the new networking config, generates the config for Netplan, and applies it so the VM gets the correct address.

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

                        @slynch OK, that's very good news then! Debian was still having issues where any configuration applied via cloud-init would just be added to the existing default DHCP config, unless you took care to build the VM without the default interfaces config beforehand.

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