3

This is my first post here so please have patience :)

I am trying to build a Ubuntu 20.04.5 image with Packer(1.8.4) on Proxmox(7.2-11). Everything seems to be working fine (get IP, reads cloud-init config via HTTP, starts the install, installs kernel) until the installation of qemu-guest-agent with subiquity. It fails to run the install command, generates a crash report and asks to hit enter to get a terminal. For 20.04.4 ISO image everything works fine with the same exactly config in Packer.

cloud-init config:

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: en
  network:
    version: 2
    ethernets:
      ens18:
        dhcp4: true
  ssh:
    install-server: true
    allow-pw: false
    disable_root: true
    ssh_quiet_keygen: true
    allow_public_ssh_keys: true
  packages:
    - qemu-guest-agent
    - sudo
  storage:
    swap:
      size: 0
    config:
      - {ptable: gpt, path: /dev/vda, preserve: false, name: '', grub_device: true, type: disk, id: disk-vda}
      - {type: partition, number: 1, device: disk-vda, flag: bios_grub, size: 1M, id: vda-grub}
      - {type: partition, number: 2, device: disk-vda, flag: boot, size: 1G, id: vda-boot}
      - {type: partition, number: 3, device: disk-vda, size: -1, id: vda-lvm}
      - {type: lvm_volgroup, name: vg-ubuntu, devices: [vda-lvm], id: vg-ubuntu}
      - {type: lvm_partition, volgroup: vg-ubuntu, id: lv-root, name: lv-root, size: -1}
      - {type: format, fstype: ext4, volume: vda-boot, id: vda-boot-fs}
      - {type: format, fstype: xfs, volume: lv-root, id: lv-root-fs}
      - {type: mount, path: /, id: m-root, device: lv-root-fs}
      - {type: mount, path: /boot, id: m-boot, device: vda-boot-fs}
  user-data:
    package_upgrade: true
    timezone: Europe/Bucharest
    users:
      - name: devops
        groups: [adm, sudo]
        lock-passwd: false
        sudo: ALL=(ALL) NOPASSWD:ALL
        shell: /bin/bash
        # passwd: your-password
        ssh_authorized_keys:
          - MyPublicKey

I have no idea if this comes from Ubuntu new iso or Packer but as the same config works for 20.04.4 I think it comes from something new that was included in last release.

Does anyone have an idea or experienced the same?

Thanks in advance for your answers!

Andi M.
  • 31
  • I tried an autoinstall config based on yours with 20.04.5 and did not have any problems. Are there any other logs from your error? Besides what is shown on the terminal you might want to use the shell within the installer to check log files in /var/log/installer/ and /target/var/log/apt/, and to run journalctl. – Andrew Lowther Nov 16 '22 at 00:03
  • @AndrewLowther i also have the same issue. as i was checking journalctl as you mentioned. it is returning error 100. this is the screenshot. i have been using a fresh ubuntu 20.04.5 iso as well. – cindrmon Jan 26 '23 at 08:24
  • 1
    @cindrmon that looks like apt is returning an error code of 100. This could be caused by a lot of things. For example, invalid apt repos or misconfigured networking. https://askubuntu.com/q/1384878/376778 https://askubuntu.com/q/1427461/376778 – Andrew Lowther Jan 26 '23 at 23:53
  • @AndrewLowther i haven't configured anything for networking at all, since my user-data doesn't contain any network section. although, i also want to ask how to configure apt in user-data. what do you think i should do to update like latest repositories and such? also, here's another link for a bin which contains my current user-data. – cindrmon Jan 27 '23 at 00:11
  • @AndrewLowther i also checked the ping from within the ubuntu installation iso, and i found out that i cannot ping any website. i feel like that isn't the intended effect and i should be able to access the internet, because i feel like it is not updating the ubuntu repositories at all. but i could be wrong. is there any other way for you to help me as well? – cindrmon Jan 27 '23 at 02:35
  • @AndrewLowther i'm actually running a command that theoretically installs qemu-guest-agent through the autoinstall script, and it somewhat doesn't even find the package at all. i tried running it on the error shell and this is the result. i don't have any clue to force curtinstall to update its sources, as i feel like it doesn't update its sources. – cindrmon Jan 27 '23 at 06:54
  • @cindrmon I suggest creating a new question for your issue – Andrew Lowther Jan 27 '23 at 23:27
  • @AndrewLowther it is still the same question for my issue. i just want to figure out why autoinstall is not using an updated sources.list when pulling qemu-guest-agent.. as you said that "the error code is 100 because of invalid apt repos or misconfigured networking." i've tried configuring the networking, but you mentioned that "removing the network directive helps solve the problem" in one of your given backlinked issues. i mean, removing qemu-guest-agent in the list of packages work, so i'm feeling that there is an issue with the sources, but i don't know how to fix that. – cindrmon Jan 28 '23 at 00:59

2 Answers2

0

Apparently, I have found a band-aid workaround with your issue...

I'm not sure if it would work for you, or if we might have the same problem with qemu-guest-agent returning Error 100.

This is my workaround solution:

I just added a late-commands directive to my user-data file where it would run apt-get update and install qemu-guest-agent after the fact.

here's a snippet of the user-data:

#cloud-config
autoinstall:
...
  late-commands:
    - curtin in-target -- apt-get update
    - curtin in-target -- apt-get install qemu-guest-agent
...

I have looked deeper into the issue to why it failed. Apparently, removing qemu-guest-agent to the list of packages makes everything work fine. When I try running the supposed command inside the error shell, it mentions that "qemu-guest-agent is not found" when it is trying to install that package. This is why I came with this solution while re-reading the docs for automated server install in ubuntu. According to the documentation with regards to running commands on the target machine, it is written there that you should add curtin in-target --target=/target -- before any command for it to run inside the target system. In this case, I want to update the sources and install qemu-guest-agent, and it worked as intended. I do feel like there could be a better solution to this, like configuring the apt directive and such. Hopefully this workaround would work on your case...

0

I saw a very similar issue to you in my environment and realized that my issue was that I needed to set my corporate proxy to allow apt/snapd reach the internet.

As per the Autoinstall Reference I needed to add the following to my user-data file:

    autoinstall:
    ...
      proxy: http://<proxy.url>:<port-number>
    ...
  • I was able to fix it with late-commands. I don't need to use proxy as the connection is direct, I control everything as it's a homelab :) – Andi M. Sep 15 '23 at 06:08