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

    Ubuntu 22 Cloud Init/Config Network & Partition Assistance

    Scheduled Pinned Locked Moved Xen Orchestra
    11 Posts 3 Posters 8.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.
    • G Offline
      gsrfan01 @Lulina
      last edited by

      @Lulina

      My cloud-inits are below, I don't mess around with building my own templates and just download the pre-made Ubuntu ones: https://cloud-images.ubuntu.com/jammy/

      #cloud-config
      hostname: {name}
      timezone: America/New_York
      users:
        - default
        - name: netserv
          passwd: passwordhash
          ssh_import_id:
            - gh:guthub_account
          sudo: ALL=(ALL) NOPASSWD:ALL
          groups: users, admin, sudo
          shell: /bin/bash
          lock_passwd: true
          ssh_authorized_keys:
            - ssh-ed25519 yourkey
      package_update: true
      packages:
        - xe-guest-utilities
      package_upgrade: true
      runcmd:
        - sudo reboot
      

      And network, though this is no longer the correct way to handle it, I've yet to update

      version: 2
      ethernets:
          eth0:
              dhcp4: false
              dhcp6: false
              addresses:
                - 172.16.100.185/24
              gateway4: 172.16.100.1
              nameservers:
                addresses:
                  - 172.16.100.21
                  - 172.16.100.22
                  - 1.1.1.1
                search:
                  - dev.themaw.tech
      
      L 1 Reply Last reply Reply Quote 0
      • L Offline
        Lulina @gsrfan01
        last edited by

        @gsrfan01
        Hi there!

        Thank you for taking the time to reply, I will try out your example inits

        I initially went with setting up my own template since I have several golden disks to use

        So you only use those above inits and don't modify cloud.cfg at all?

        I appreciate the help!

        1 Reply Last reply Reply Quote 0
        • G Offline
          gsrfan01
          last edited by

          No modifications at all. I download the OVA, import into Xen Orchestra, usually change the cpu to 2 cores and ram to 2gb, then convert to template.

          I select the template and the cloud configs when creating a new VM. It expands the file system, sets up the user, imports SSH keys, updates packages, installs the tools, then reboots.

          You can expand it to add addition users, keys, packages, etc.

          R L 2 Replies Last reply Reply Quote 0
          • R Offline
            rajudm @gsrfan01
            last edited by

            @gsrfan01 I have taken up XCP-NG for setting up home lab (K8s), and would take your suggestions in creating the template. I would post any issues encountered here to bring up VM instances. thanks

            1 Reply Last reply Reply Quote 0
            • L Offline
              Lulina @gsrfan01
              last edited by

              @gsrfan01
              Good day Gsrfan

              I have managed to get the network going using your example network init, thank you it helped a bunch!

              So far I can't access the test VM, the default ubuntu user and my custom user don't accept the credentials.
              I have seen online it's possible to define the ssh keys in the init, is it a simple enough alternative to Github?

              Thank you 🙂

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                rajudm @Lulina
                last edited by

                @Lulina I was trying to have the cloud config and network saved but got error with redis. I couldn't progress further. Do you have the template for those configs.

                L 1 Reply Last reply Reply Quote 0
                • L Offline
                  Lulina @rajudm
                  last edited by

                  @rajudm
                  Hi there

                  We just need some more info from your side
                  What error did you get?
                  Which distro are you using to deploy the VMs?

                  R 1 Reply Last reply Reply Quote 0
                  • R Offline
                    rajudm @Lulina
                    last edited by

                    @Lulina using cloud image from ubuntu 22.04 --> ubuntu-22.04-server-cloudimg-amd64.ova

                    While creating config's i get errors

                    what would be the ideal cloud config and network config for the following.

                    Cloud config
                    Name
                    Template
                    #cloud-config
                    #hostname: {name}%
                    #ssh_authorized_keys:

                    - ssh-rsa <myKey>

                    #packages:

                    - htop

                    0 items
                    ID Name
                    No items found
                    Network config
                    Name
                    Template

                    With the same image got the VM template created and VM created in proxmox following Jay Linux's video. A similar one is required for XCP-NG to make popular in community edition. I was looking at exporting from Proxmox and Importing into XCP-NG. Not sure if that would work either given the networking variability among hypervisors.

                    G 1 Reply Last reply Reply Quote 0
                    • G Offline
                      gsrfan01 @rajudm
                      last edited by

                      If you don't want to import Github keys at all, you can remove that portion and specify it under ssh_authorized_keys for each user built from cloud-init.

                      #cloud-config
                      hostname: {name}
                      timezone: America/New_York
                      users:
                        - default
                        - name: YOURUSER
                          passwd: YOURPASSWORDHASH
                          sudo: ALL=(ALL) NOPASSWD:ALL
                          groups: users, admin, sudo
                          shell: /bin/bash
                          lock_passwd: true
                          ssh_authorized_keys:
                            - ssh-rsa YOURKEY
                      package_update: true
                      packages:
                        - xe-guest-utilities
                        - htop
                      package_upgrade: true
                      

                      If you want to be able to log in from the console instead of only SSH using keys, change lock_passwd: true to lock_passwd: false

                      1 Reply Last reply Reply Quote 0
                      • L Offline
                        Lulina
                        last edited by

                        Hi there Gsrfan

                        Apologies for the delayed response, I had to shelf this passion project to focus on other work
                        So far managed to get the host, static IP, packages, users & their keys/password etc sorted with the init

                        I was working last on lvm partitions, to grow them and that ended up a bit of a mess

                        I might return to this at a later stage but I found your help and advice invaluable to getting the config to where it is now

                        Thank you so much 🙂

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