Cloudinit not used by VM created by QEMU

hamuto

New Member
Dec 2, 2021
4
1
3
26
I have a CentOS VM that need to be used with `cloudinit`.

Using libvirt, I am creating VM on Proxmox with Scaleway.
I have an ansible file that create a VM name CentOS_Base, the most important commands are:

Bash:
# Downloading a CentOS-7-x86_64-GenericCloud-1809.qcow2
curl https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1809.qcow2

# Create root disk based on cloud init img
qemu-img create -b CentOS-7-x86_64-GenericCloud.qcow2 -f qcow2 -F qcow2 CentOS_Base.qcow2 20G

# Create iso image for cloud init
genisoimage -output cidata.iso -volid cidata -joliet -r user-data meta-data

# Create the VM
virt-install --connect qemu:///system --import --name CentOS_Base --ram 2048 --vcpus 2
--disk CentOS_Base.qcow2,format=qcow2,bus=virtio --disk cidata.iso,device=cdrom
--network network:default,model=virtio --os-type=linux --os-variant=rhel7 --noautoconsole


user-data and meta-data are already created.

I previously posted a question on how to convert the libvirt VM to QEMU, because Proxmox GUI doesn't handle libvirt virtual machine.

Bash:
qm create 9007 --name CentOS-vm1 --memory 2048 --net0 virtio,bridge=vmbr1 --serial0 socket --vga serial0 -ostype l26 -sockets 1 -cores 2 -cpu host -numa 1 -ide2 GlusterFs:iso/cidata.iso
qm importdisk 9007 CentOS_Base.qcow2 GlusterFs -format qcow2
qm set 9007 --scsi0 GlusterFs:9007/vm-9007-disk-0.qcow2 --scsihw virtio-scsi-pci
qm set 9007 --boot order=scsi0
qm resize 9007 scsi0 32G

The above commands do create the QEMU VM, I can connect to it from the GUI.

But the CD-ROM ISO with cloud-init config I've created doesn't seems to work, when I try to connect with the user and password from the user-data yaml file. I get that the message from Login incorrect

I tried to remove the cloud init iso, and create a cloud init drive.

Bash:
qm create 9007 --name CentOS-vm1 --memory 2048 --net0 virtio,bridge=vmbr1 --serial0 socket --vga serial0 -ostype l26 -sockets 1 -cores 2 -cpu host -numa 1
qm importdisk 9007 CentOS_Base.qcow2 GlusterFs -format qcow2
qm set 9007 --scsi0 GlusterFs:9007/vm-9007-disk-0.qcow2 --scsihw virtio-scsi-pci
qm set 9007 --boot order=scsi0
qm resize 9007 scsi0 32G

qm set 9007 --ide0 GlusterFs:cloudinit
qm set 9007 --ciuser hamuto --cipassword root --sshkeys ~/.ssh/id_rsa.pub

When I connect to the VM, I have the same problem: Login incorrect.

The CentOS_Base.qcow2 is created by:
 
There are two things you can do to troubleshoot this:

1) use "qm cloudinit dump" to examine the generated cloudinit file
2) Edit the image to have a known password, boot with cloudinit option and examine the logs to see if any errors are generated.

In general what you are doing should work. There is not enough information to say why its failing for you.

P.S.
Although this tech note is not for modern cloudinit base, it might give you some ideas:
https://kb.blockbridge.com/technote/proxmox-cirros/


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

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!