Hi all.
I have been struggling a couple days trying to get my cloud-init working on a clone from a template. I'm running Proxmox 8.2.4 on a 3 node cluster. I'm only working from one node
I'm automating this process through qm commands . Build the template from Ubuntu 22.04 cloud image, set the cloud-init parameter, turn VM into a template, then clone it.
If I strictly use qm commands to set cloud-init parameters, it seems to work fine. But either the parameters are limited or I'm not using them all due to lack of knowledge.
Ultimately, I would like to use a cloud.cfg file. But every time I try to use cloud.cfg, either stand alone (no qm ci commands) or a combination, the clone builds but no ip is assigned or I can't get into the host using the defined user "srvadm" or "ubuntu".
If I remove the two lines:
qm set ${VID} --cicustom "user=local:snippets/cloud.cfg"
qm cloudinit update ${VID}
then everything seems to wor but
Can I use both cloud.cfg and qm --ci commands? Any ideas or does anyone have sample scripts that do work?
Another interesting observation. When I try to use the cloud.cfg, the login is
ubuntu login:
But when I don't use cloud.cfg, then my login is:
myclone login:
Here are the commands I was trying to use when logged into the proxmox host.
VID=9000
VID_CLONE=150
VM_NAME=myclone
qm create ${VID} --memory 1024 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0
qm disk import ${VID} /tmp/jammy-server-cloudimg-amd64.img local -format qcow2
qm set ${VID} --scsihw virtio-scsi-pci --scsi0 local:${VID}/vm-${VID}-disk-0.qcow2,size=8,discard=on,ssd=1
qm resize ${VID} scsi0 4G
qm set ${VID} --scsihw virtio-scsi-pci --ide2 local:cloudinit
qm set ${VID} --ciuser srvadm
qm set ${VID} --cipassword $(openssl passwd -6 adminpass)
qm set ${VID} --ipconfig0 ip=dhcp
qm set ${VID} --sshkeys ~/.ssh/id_ed25519.pub
cat << EOF > /var/lib/vz/snippets/cloud.cfg
#cloud-config
runcmd:
- date > /etc/birth_certificate
EOF
qm set ${VID} --cicustom "user=local:snippets/cloud.cfg"
qm cloudinit update ${VID}
qm set ${VID} --boot c --bootdisk scsi0
qm set ${VID} --serial0 socket --vga serial0
qm set ${VID} --agent enabled=1
qm template ${VID}
qm clone ${VID} ${VID_CLONE} --name ${VM_NAME} --full
I have been struggling a couple days trying to get my cloud-init working on a clone from a template. I'm running Proxmox 8.2.4 on a 3 node cluster. I'm only working from one node
I'm automating this process through qm commands . Build the template from Ubuntu 22.04 cloud image, set the cloud-init parameter, turn VM into a template, then clone it.
If I strictly use qm commands to set cloud-init parameters, it seems to work fine. But either the parameters are limited or I'm not using them all due to lack of knowledge.
Ultimately, I would like to use a cloud.cfg file. But every time I try to use cloud.cfg, either stand alone (no qm ci commands) or a combination, the clone builds but no ip is assigned or I can't get into the host using the defined user "srvadm" or "ubuntu".
If I remove the two lines:
qm set ${VID} --cicustom "user=local:snippets/cloud.cfg"
qm cloudinit update ${VID}
then everything seems to wor but
Can I use both cloud.cfg and qm --ci commands? Any ideas or does anyone have sample scripts that do work?
Another interesting observation. When I try to use the cloud.cfg, the login is
ubuntu login:
But when I don't use cloud.cfg, then my login is:
myclone login:
Here are the commands I was trying to use when logged into the proxmox host.
VID=9000
VID_CLONE=150
VM_NAME=myclone
qm create ${VID} --memory 1024 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0
qm disk import ${VID} /tmp/jammy-server-cloudimg-amd64.img local -format qcow2
qm set ${VID} --scsihw virtio-scsi-pci --scsi0 local:${VID}/vm-${VID}-disk-0.qcow2,size=8,discard=on,ssd=1
qm resize ${VID} scsi0 4G
qm set ${VID} --scsihw virtio-scsi-pci --ide2 local:cloudinit
qm set ${VID} --ciuser srvadm
qm set ${VID} --cipassword $(openssl passwd -6 adminpass)
qm set ${VID} --ipconfig0 ip=dhcp
qm set ${VID} --sshkeys ~/.ssh/id_ed25519.pub
cat << EOF > /var/lib/vz/snippets/cloud.cfg
#cloud-config
runcmd:
- date > /etc/birth_certificate
EOF
qm set ${VID} --cicustom "user=local:snippets/cloud.cfg"
qm cloudinit update ${VID}
qm set ${VID} --boot c --bootdisk scsi0
qm set ${VID} --serial0 socket --vga serial0
qm set ${VID} --agent enabled=1
qm template ${VID}
qm clone ${VID} ${VID_CLONE} --name ${VM_NAME} --full