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

    Created cloud config, but can't select it when creating a new VM.

    Scheduled Pinned Locked Moved Xen Orchestra
    36 Posts 6 Posters 10.7k Views 6 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.
    • G Offline
      geek-baba @olivierlambert
      last edited by

      @olivierlambert I will certainly try that, however I wanted to customize it for k8s cluster, so was wondering if the old guide need updating if at all.

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

        If we can find exactly why, yes we could improve/fix it 🙂

        G 1 Reply Last reply Reply Quote 0
        • G Offline
          geek-baba @olivierlambert
          last edited by

          @olivierlambert - ok, I will continue troubleshooting, the guide is pretty basic, i.e. install plain vanilla debian and install couldinit so was not sure what could go wrong.

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

            Partition ID for Cloudinit is the first step to check.

            apt-get install cloud-init cloud-initramfs-growroot
            
            diff /usr/lib/cloud-init/ds-identify.ORIGINAL /usr/lib/cloud-init/ds-identify
            236a237,238
            >             LABEL_FATBOOT=*) label="${line#LABEL_FATBOOT=}";
            >                               labels="${labels}${line#LABEL_FATBOOT=}${delim}";;
            
            /etc/cloud/cloud.cfg
            
            ssh_deletekeys: true
            
            datasource_list: [ ConfigDrive, None ]
            datasource:
              ConfigDrive:
                dsmode: local
            
            E 1 Reply Last reply Reply Quote 0
            • E Offline
              eperez539 @olivierlambert
              last edited by eperez539

              @olivierlambert just tried to go through the process again from what the example gave. Included the extra lines you mentioned above for the datasource. But it is still not seeing any of the custom cloud init settings that I configured.

              Is the template VM somehow badly configured? Is there anything on here that is outdated: https://xen-orchestra.com/blog/centos-cloud-template-for-xenserver/

              I'll continue debugging this issue but would be nice to have a guide on how to make cloud init work. Seems like there is something either missing or not working on the current guide (maybe XO bug?).

              Looking at the docs again, seems like the cloud-init config didn't really work:

              Hostname is set to: cloudtest

              200ec739-6000-417d-bbc2-01752045e728-image.png

              Result (host name is not correct )

              f6e92cac-7372-4432-8878-cd341f499d61-image.png

              G 1 Reply Last reply Reply Quote 0
              • G Offline
                geek-baba @eperez539
                last edited by

                @eperez539 this guide wont work, this is what I did, installed XOA, created the VM from HUB, modified it and converted again to the template.

                E 1 Reply Last reply Reply Quote 0
                • E Offline
                  eperez539 @geek-baba
                  last edited by

                  @geek-baba Thanks, do you happen to have some steps on the additional changes you made to the VM before converting in to the template?

                  G 1 Reply Last reply Reply Quote 0
                  • G Offline
                    geek-baba @eperez539
                    last edited by

                    @eperez539 just install anything you want, for example I added docker and kubernetes and converted it to template and now when I create new VM it retains everything.

                    E 1 Reply Last reply Reply Quote 0
                    • E Offline
                      eperez539 @geek-baba
                      last edited by

                      @geek-baba oh ok, so are you bypassing cloud init altogether? How do you handle the network config? I was hoping to at least setup network + ssh key and then I could mange with Ansible after that.

                      Initially tried using Terraform with XO, but this cloud init issue may be the problem why I was having an issue getting them to work together.

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        geek-baba
                        last edited by geek-baba

                        no I am not bypassing the cloudinit, I am using a working template that have local cloud config that I was not able to get it working on my own. if you use the template, you would see 2 drives under disk like below.

                        alt text

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          MrMike
                          last edited by

                          @olivierlambert said in Created cloud config, but can't select it when creating a new VM.:

                          your VM to understand why it doesn't fetch your config.

                          There was a an update to cloud-init recently and it broke the template I've been using to deploy our VMs. What's i've noticed so far is that it overwrites the network configuration files for centos in /etc/sysconfig/network-scripts/ifcfg-eth0. I got around that issue by adding the network: configuration: ignore to the cloud.cfg file..

                          I then figured maybe it's time to update my template, so I went ahead and did just that using the same guide found here.

                          Once the VM starts it also fails to load the config drive automatically, so I'm thinking the documentation will need to get some sort of refresh .. Once I figure it out, I can show what worked for me here if no one else figured it out first.

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

                            Keep us posted please 🙂

                            M 1 Reply Last reply Reply Quote 0
                            • M Offline
                              MrMike @olivierlambert
                              last edited by

                              @olivierlambert
                              I got it working by applying the diff you posted above. I edited the ds-identity file and added the fatboot label. I then added the datasource entries to cloud.cfg.

                              I converted to a template and 1st bootup it updated automaticaly and ran everything I had already setup in the cloud.cfg.

                              I would say that the blog post from December 2015 or the wiki needs to be updated with that new information. Also worth mentioning is that unless a network configuration is specified in the cloud.cfg file you need to add this snippet at the bottom so that any future customization of the network interfaces doesn't get wiped up by cloud-init:

                              network:
                                config: disabled
                              
                              
                              E 1 Reply Last reply Reply Quote 0
                              • E Offline
                                eperez539 @MrMike
                                last edited by

                                @MrMike could you please post the changes to ds-identity file? Also, I don't see the /usr/lib/cloud-init/ds-identify.ORIGINAL file. Is this something that gets created after the new VM is created?

                                M 1 Reply Last reply Reply Quote 0
                                • M Offline
                                  MrMike @eperez539
                                  last edited by

                                  @eperez539

                                  You need to add the following 2 lines to /usr/lib/cloud-init/ds-identify at or around line 245 if your file is different than mine.

                                           LABEL_FATBOOT=*) label="${line#LABEL_FATBOOT=}";
                                                             labels="${labels}${line#LABEL_FATBOOT=}${delim}";;
                                  

                                  The file diff /usr/lib/cloud-init/ds-identify.ORIGINAL is just a backup of the original file. You should do the same in case you need to roll back changes one day.

                                  Here's the end result in my file (see line 245 where I added the above):

                                      236     for line in "$@"; do
                                      237         case "${line}" in
                                      238             DEVNAME=*)
                                      239                 [ -n "$dev" -a "$ftype" = "iso9660" ] &&
                                      240                     isodevs="${isodevs},${dev}=$label"
                                      241                 ftype=""; dev=""; label="";
                                      242                 dev=${line#DEVNAME=};;
                                      243             LABEL=*) label="${line#LABEL=}";
                                      244                      labels="${labels}${line#LABEL=}${delim}";;
                                      245             LABEL_FATBOOT=*) label="${line#LABEL_FATBOOT=}";
                                      246                              labels="${labels}${line#LABEL_FATBOOT=}${delim}";;
                                      247             TYPE=*) ftype=${line#TYPE=};;
                                      248             UUID=*) uuids="${uuids}${line#UUID=}$delim";;
                                      249         esac
                                      250     done
                                  
                                  E 1 Reply Last reply Reply Quote 0
                                  • E Offline
                                    eperez539 @MrMike
                                    last edited by

                                    @MrMike Great, thanks. I'll try this out.

                                    M 1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      MrMike @eperez539
                                      last edited by

                                      @eperez539 good luck

                                      E 1 Reply Last reply Reply Quote 1
                                      • E Offline
                                        eperez539 @MrMike
                                        last edited by

                                        @MrMike nope, not working.

                                        • Created VM
                                        • Installed guest-tools
                                        • Installed cloud init, cloud-initramfs-growroot
                                        • Updated /etc/cloud/cloud.cfg
                                        • Updated /usr/lib/cloud-init/ds-identify with lines given above
                                        • Created template
                                        • Created new vm from template using cloud init config on XO
                                        • New VM has nothing from the cloud init config...

                                        I could see how you could tweak the /etc/cloud/cloud.cfg with the users, etc. But cloud.cfg should have minimal settings on it. All the settings and configuration should come from the cloud init config in XO.

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

                                          Check if you can read the config file in the extra disk while inside the VM. If yes, it's clearly a cloudinit config issue 🙂

                                          E 1 Reply Last reply Reply Quote 0
                                          • E Offline
                                            eperez539 @olivierlambert
                                            last edited by

                                            @olivierlambert I see the drive attached to the new VM but it is not mounted. After mounting, I can see the contents of cloud-init config and everything looks ok unless I missed something:

                                            drwxr-xr-x  3 root root 16384 Jan  1  1970 ./
                                            drwxr-xr-x 24 root root  4096 May 22 18:58 ../
                                            -rwxr-xr-x  1 root root    50 May 22 18:54 meta-data*
                                            -rwxr-xr-x  1 root root   104 May 22 18:54 network-config*
                                            drwxr-xr-x  3 root root  2048 May 22 18:54 openstack/
                                            -rwxr-xr-x  1 root root   469 May 22 18:54 user-data*
                                            root@cloudbase:/mnt# cat user-data
                                            #cloud-config
                                            hostname: testingtheothertime0
                                            timezone: America/New_York
                                            package_update: true
                                            package_upgrade: true
                                            packages:
                                              - htop
                                              - tree
                                              - vim
                                              - ffmpeg
                                            write_files:
                                              - content: |
                                                network:
                                                  ethernets:
                                                    eth0:
                                                      addresses:
                                                        - 192.168.0.22/24
                                                  gateway4: 192.168.0.1
                                                  nameservers:
                                                    addresses:
                                                      - 192.168.0.1
                                                version: 2
                                                path: /etc/netplan/00-installer-config.yaml
                                            runcmd:
                                              - [ netplan, apply ]
                                            root@cloudbase:/mnt# cat network-config
                                            #network:
                                            #  version: 1
                                            #  config:
                                            #  - type: physical
                                            #    name: eth0
                                            #    subnets:
                                            #      - type: dhcproot@cloudbase:/mnt#
                                            root@cloudbase:/mnt# cat meta-data
                                            instance-id: 3824858a-0679-2863-5416-e03640479e8c
                                            root@cloudbase:/mnt#
                                            
                                            

                                            From the cloud config, the packages were not installed. Also, tried the do the networking in different ways but nothing worked.

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