[SOLVED] Proxmox cloud-init not working on Ubuntu 24 Server/Desktop

midgetseeker

New Member
Mar 17, 2023
10
2
3
Hello all,

I'm in the process of adopting Ubuntu 24 as the next upgrade in my infra but on validation it looks like cloud-init doesn't work anymore.

My host:

root@proxmox-server:~# pveversion
pve-manager/8.1.4/ec5affc9e41f1d79 (running kernel: 6.5.11-8-pve)

Later edit:

Turns out that cloud-init config is disabled by default on U24 server/desktop.
To enable it AFTER you've added a cloud-init drive and applied the pve config you need to run the below command and reboot:
Code:
sudo cloud-init clean --machine-id

Hope this helps others from head scratching.
Regards.
 
Ubuntu produces specific images for cloud deployment - https://cloud-images.ubuntu.com/. The Desktop and Server variants are not meant for cloud deployment, so its not surprising that they lack CloudInit by default.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
I know that but the cloud-init datasource from proxmox works on Ubuntu 22 just fine.

I have no way to automate my VM deployment if cloud-init is not working. I'm using the ansible proxmox modules to provision VM's from templates in a playbook.

It works ok on U22, but U24 is... microsofty
 
Turns out that U24 doesn't like the IDE bus anymore.

It's happy to boot from an IDE bus cd-rom but not load cloud-init from there.

The fix seems to need a change from VirtIO-SCSI-Single to VirtIO-SCSI as the main controller and map the cloud-init drive to a scsi bus id.

The example config that works for me looks like this:
agent: enabled=1,fstrim_cloned_disks=1
bios: ovmf
boot: c
bootdisk: scsi0
cipassword: /etc/yomomma
ciupgrade: 0
ciuser: yomamma
cores: 4
cpu: x86-64-v2-AES
efidisk0: yomamma_disks:vm-000-disk-0,efitype=4m,pre-enrolled-keys=1,size=4M
ipconfig0: ip=192.168.500.500/24,gw=192.168.500.500
localtime: 1
memory: 4096
meta: creation-qemu=8.1.5,ctime=1714376435
name: u24-test
nameserver: 192.168.500.500
net0: virtio=12:23:34:45:56:67,bridge=vmbr0,firewall=1
numa: 0
onboot: 1
ostype: l26
scsi0: yomamma_disks_disks:vm-000-disk-1,iothread=1,size=100G,ssd=1
scsi1: yomamma_disks_disks:vm-000-cloudinit,media=cdrom
scsihw: virtio-scsi-pci
searchdomain: local service.consul node.consul
smbios1: uuid=yomamma
sockets: 1
sshkeys: ssh-rsa yomamma
vga: memory=128
vmgenid: yomamma
 
I made a few experiments and for my setup (ubuntu 24.0.4.1 minimal on proxmox 8.3.2) both ide and SCSI cloud-init drives are working fine for Seabios on 440fx machine. However, non of the variations is able to create user `admin` (and that cost me a night of scratching the head). As soon as I stick to default `ubuntu` user or change username to something random, all is working fine.
 
Last edited:
Admin is likely a reserved name that possibly already exists.
Cloudinit creates a group that matches the username, group "admin" already exists. So it is, in a way, reserved. One can probably create such user with custom cloudinit.

./log/cloud-init.log
Code:
2025-01-04 17:17:53,299 - log.py[DEPRECATED]: 'user' of type string is deprecated in 22.2 and scheduled to be removed in 27.2. Use 'users' list instead.
2025-01-04 17:17:53,310 - util.py[WARNING]: Failed to create user admin
2025-01-04 17:17:53,313 - util.py[WARNING]: Running module users_groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed
2025-01-04 17:17:53,761 - util.py[WARNING]: Applying SSH credentials failed!

2025-01-04 17:17:53,311 - util.py[DEBUG]: Failed to create user admin
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 755, in add_user
subp.subp(useradd_cmd, logstring=log_useradd_cmd)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 298, in subp
raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', 'admin', '--comment', 'Ubuntu', '--groups', 'adm,cdrom,dip,lxd,sudo', '--shell', '/bin/bash', '-m']
Exit code: 9
Reason: -
Stdout:
Stderr: useradd: group admin exists - if you want to add this user to that group, use -g.
2025-01-04 17:17:53,313 - handlers.py[DEBUG]: finish: init-network/config-users_groups: FAIL: running config-users_groups with frequency once-per-instance
2025-01-04 17:17:53,313 - util.py[WARNING]: Running module users_groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed
2025-01-04 17:17:53,313 - util.py[DEBUG]: Running module users_groups (<module 'cloudinit.config.cc_users_groups' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py'>) failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/config/modules.py", line 286, in _run_modules
ran, _r = cc.run(
^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 71, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 156, in run
results = functor(**args)
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_users_groups.py", line 240, in handle
cloud.distro.create_user(user, **config)
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 813, in create_user
self.add_user(name, **kwargs)
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 758, in add_user
raise e
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 755, in add_user
subp.subp(useradd_cmd, logstring=log_useradd_cmd)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 298, in subp
raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['useradd', 'admin', '--comment', 'Ubuntu', '--groups', 'adm,cdrom,dip,lxd,sudo', '--shell', '/bin/bash', '-m']
Exit code: 9

Code:
root@cli-ubuntu24-04:/home/ubuntu# grep admin /etc/group
admin:x:110:
root@cli-ubuntu24-04:/home/ubuntu# useradd admin --comment "Ubuntu" --groups adm,cdrom,dip,sudo --shell /bin/bash -m
useradd: group admin exists - if you want to add this user to that group, use -g.
root@cli-ubuntu24-04:/home/ubuntu# echo $?
9


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited: