pve 6.4 cloud-init doesn't work in ubuntu 22.04

Dec 25, 2017
23
0
21
36
I have installed cloud-init on kvm debian 11, and it's work. I did the same for Ubuntu 22.04 but it doesn't work
Скриншот 20-06-2022 160336.jpg
And:
1655730317099.png
But the user is not created. And IP didn't change:
1655730410479.png

How to understand what's wrong?
 
There is generally much more logging available when cloud-init runs. There is a cloudinit.log file and other evidence. Most of it is in /var.

If, when you login to VM, you can mount the cloud-init ISO and it appears ok, then issue is in how you prepared the OS. May be cloud-init not started, may be install failed. Could be many different things.

I suggest you use a cloud image of Ubuntu and try with it.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I'm having the same issue. I'm using the jammy (22.04.1) cloud image (daily build). Same method works perfectly with the focal cloud image. I don't even see cloud-init executing in the startup console output. Problematic part is that since cloud init doesn't actually run there was no way to access the system.
I did manage to get into the system using `virt-customize` to set a root password as mentioned here.

After running cloud-init manually using systemctl enable --now cloud-init, the hostname etc did get updated and the network settings did get applied after reboot. Unfortunately it doesn't work automatically on boot. I suspect it has something to do with the "NoCloud" datasource being deprecated (although I don't have much idea about what that means).
 
any solution in this case? we face same situation.. cloud-init does not work under proxmox 7.2.3
 
If you need help, then its worth investing some time in crafting a well described question. Including versions, VM configuration, log outputs, troubleshooting steps you took. The topic of this thread is PVE 6.x/cloudinit. I would recommend opening a separate thread for any issues that you have with 7.3.

As an example the following script works just fine with both Ubuntu 22 and 20:
#!/bin/bash
set -euo pipefail

: ${STORAGE:="blockbridge"}
: ${VMID:="2000"}
: ${MYDISK:="vm-$VMID-disk-0"}
: ${DEVICE:="scsi0"}
: ${NAME:="vm$VMID"}

: ${OSIMAGE:="cirros-0.5.1-x86_64-disk.img"}

ISO="/mnt/pve/bbnas/template/iso"

qm create $VMID --memory 512 --name $NAME --socket 1 --onboot no
qm importdisk $VMID $ISO/$OSIMAGE $STORAGE --format raw
qm set $VMID --scsihw virtio-scsi-pci --$DEVICE $STORAGE:$MYDISK
qm set $VMID -net0 virtio,bridge=vmbr0,firewall=1
qm set $VMID --ide2 $STORAGE:cloudinit
qm set $VMID --serial1 socket --vga serial1
qm set $VMID -args "-chardev file,id=char0,mux=on,path=/tmp/serial.$VMID.log,signal=off -serial chardev:char0"
qm set $VMID --boot c --bootdisk $DEVICE
qm set $VMID -ipconfig0 ip=dhcp
qm set $VMID --cipassword testpassword --ciuser ubuntu
qm set $VMID -sshkeys ~/.ssh/id_rsa.pub

ie:
Code:
STORAGE=local-lvm OSIMAGE=focal-server-cloudimg-amd64.img ./vm_create.sh
STORAGE=local-lvm OSIMAGE=ubuntu-22.04-minimal-cloudimg-amd64.img ./vm_create.sh


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
One more note: above I am able to login with ssh key. Forcing a password does not work out of the box.

On Ubuntu 20.04+ when one looks into /etc/ssh/sshd_config the following is set by default:
PasswordAuthentication no

Which means you _MUST_ authenticate to Cloud Image with an ssh key. So keep that in mind. Of course, nothing stops you from modifying or building your own template.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
I appreciate the problem is probably with the ubuntu cloud images, they just don't seem to run the proxmox cloudinit scripts. Its weird, I was testing this morning - have been tweaking settings and reattached the ubuntu image and it just worked.

Detached and deleted the disk, then reattached the image and it hasn't worked since, exact same vm and settings.

Installing using a ubuntu server boot iso works, but it has its own cloudinit already installed that I have to clear first
  • apt-get purge cloudinit
  • rm -rf /etc/cloud
  • apt-get install cloudint

Works after that.

The bionic ubuntu cloud images works reliably, its the 22.04 jammy ones that won't.
 
I think I may have resolved the issue - got suspicious that the CloudInit CDROM might not be detected reliably by the ubuntu image. I changed the machine type from q35 to i440fx and it started running the cloudinit reliably.

Converted to template and clones are running the cloudinit to.
 
  • Like
Reactions: ergosteur
I was facing the same issue. So I have fixed this issue by removing the running these commands and now its working for me.
# apt purge cloud-init
# apt update -y
# apt install cloud-init
# sudo mv /var/lib/cloud/data/upgraded-network /var/lib/cloud/data/upgraded-network.backup
# sudo cloud-init init
# man cloud-init

Hoping these set of commands will help in fixing your issue also.
 
Last edited:
I was facing the same issue. So I have fixed this issue by removing the running these commands and now its working for me.
# apt purge cloud-init
# apt update -y
# apt install cloud-init
# sudo mv /var/lib/cloud/data/upgraded-network /var/lib/cloud/data/upgraded-network.backup
# sudo cloud-init init
# man cloud-init

Hoping these set of commands will help in fixing your issue also.
how do I "run" these in the image/VM right after creation? only fixed/static IP assignments, so networking can't rely on DHCP
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!