Cloud-init VM with dhcp IP uses wrong hostname

jamieInCLT

New Member
Jan 12, 2024
5
0
1
Hi folks- I'm new to Proxmox and I've run into a snag. I've got a script (below) to create a cloud-init template of Ubuntu Server (22.04 LTS), based on TechnoTim's video & blog.

It creates the image, marks it as a template, and I even got it to resize the disk.

The problem starts after I clone the template. When it starts up and tries to get an IP address from the DHCP server the hostname isn't what's sent to and registered in the DHCP server, but rather, it's just "ubuntu", and, if I make multiple clones, they're all "ubuntu". The hostname inside the VM is correct.

I've tried rebooting the newly-cloned vm, power-cycling it, renewing the DHCP, and resetting the hostname via hostnamectl, but each time it's still ubuntu. Is this a known issue? Anything else I can try, even if they're just manual steps?

Thanks,

-jamie

Here's the script, with a fake user/password, in case it helps anyone else

Code:
#!/bin/bash

[ -f "jammy-server-cloudimg-amd64.img" ] || \
   curl -LO --silent https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img

qm create 9000 --memory 4096 --core 2 --name ubuntu-cloud-jammy --net0 virtio,bridge=vmbr0,tag=100
qm importdisk 9000 jammy-server-cloudimg-amd64.img local-zfs
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-zfs:vm-9000-disk-0
qm set 9000 --ide2 local-zfs:cloudinit
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --cipassword="cloudpass" --ciuser=clouduser
qm set 9000 --ipconfig0 ip=dhcp
qm set 9000 --sshkey pub-key
qm resize 9000 scsi0 +10G
qm template 9000

qm clone 9000 111 --name wario --full
 

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!