kubernetes-sigs/image-builder

Ubuntu-2204, qemu - Cloud-init configuration is disabled by the subiquity autoinstaller

matofeder opened this issue · 3 comments

Subiquity autoinstaller does not allow further Ubuntu-2204, qemu image configuration by the cloud-init NoCloud or Cloud datasources.

What steps did you take and what happened:

Steps to reproduce the issue:

  1. Build qemu Ubuntu 22.04
make build-qemu-ubuntu-2204
  1. Create custom cloud-init config e.g.:
cat >user-data <<EOF
#cloud-config
users:
  - name: test
    plain_text_passwd: test
    groups: sudo
    lock-passwd: false
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
EOF
  1. Create a local disc from the user-data file
cloud-localds seed.img user-data
  1. Create a new virtual machine using the seed.img and ubuntu22.04, e.g.:
virt-install \
  --name ubuntu2204_cloud_init_test \
  --memory 2048 \
  --vcpus 2 \
  --disk ubuntu-2204-kube-v1.23.15,device=disk,bus=virtio \
  --disk seed.img,device=cdrom \
  --os-variant ubuntu22.04 \
  --noautoconsole \
  --network network=default,model=virtio \
  --import
  1. User test which should be created by cloud-init via seed.img is not there

What happened:

Note:
Inspection of the ubuntu22.04 image has been done using an unlocked builder user:

-      "shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S -E sh -c 'usermod -L {{user `ssh_username`}} && {{user `shutdown_command`}}'",
+      "shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S -E sh -c '{{user `shutdown_command`}}'",
  1. Subiquity autoinstaller creates cloud-init 99-installer.cfg file that restricts data sources only to None
root@localhost:~# cat /etc/cloud/cloud.cfg.d/99-installer.cfg 
datasource:
  None:
    metadata:
      instance-id: 35edaee4-d23a-4a90-8afd-27d827d25cb4
    userdata_raw: "#cloud-config\ngrowpart:\n  mode: 'off'\nlocale: en_US.UTF-8\n\
      resize_rootfs: false\nssh_pwauth: true\nusers:\n- groups:\n  - adm\n  - cdrom\n\
      \  - dip\n  - plugdev\n  - lxd\n  - sudo\n  lock-passwd: false\n  name: builder\n\
      \  passwd: $6$xyz$UtXVazU08Q5b8AW.TJ3MPYZglyXa3Ttf2RCel8MCUPlEYO1evWxeWBhZ2QqivU/Ij4tqYAxMCqc2ujEM4dMSe1\n\
      \  shell: /bin/bash\n  sudo: ALL=(ALL) NOPASSWD:ALL\n"
datasource_list:
- None
  1. The above caused any other data source e.g. NoCloud, OpenStack ... is not discovered by the cloud-init
  • This image-builder uses ISO image which contains subiquity autoinstaller
  • Autoinstaller is used in the Ubuntu22.04 building process here
  • Subiquity autoinstaller expects that the ISO image is used on bare metal, therefore it does not expect additional image configuration via cloud-init
  • The recommended way for the cloud is the Ubuntu cloud image
  • Further discussion, explanation, and details could be found here

What did you expect to happen:

Have a qemu-ubuntu-2204 image that could be further configured via the cloud-init config file in the cloud

Anything else you would like to add:

If we want to still use Ubuntu 22.04 ISO image we should remove files left by the subiquity autoinstaller. These files (e.g. /etc/cloud/cloud.cfg.d/99-installer.cfg , /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg) disable further image configuration.

  • From cloud-init 22.3 and subiquity 22.10.1 there is a support to remove mentioned files by simple cloud-init clean call, which should be performed at the end of the image build.
  • Current version of subiquity used in the base image-builder ISO image (ubuntu-22.04.1-live-server-amd64.iso) is lower than 22.10.1, therefore manual removal is needed
  • Alternatively, subiquity could be updated on the current (ubuntu-22.04.1-live-server-amd64.iso) ISO image using refresh-installer autoinstall config key
  • Alternatively, the newer subiquity version could be available in ubuntu-22.04.2 live server ISO (needs to be investigated)

Note: Special thanks to @chess-knight for the deep investigation and tests

/kind bug

This means that subiquity-built images are unusable in the cloud, ouch.

#1105
Seems like we have PR to address this

resolved by #1105