I have an issue with CloudInit on Proxmox 7.2 and Ubuntu 22.04, that the hostname of the VM given in the Proxmox GUI will not be set in the VM.
As basis i use the CloudImage
I have two CloudInit files, one for user and one for vendor (see below), which both get added to the template. The template gets created with the following steps:
Afterwards i clone my VM in the Proxmox GUI from the template created with for example the following options:
When starting the VM everything get's set as expected, but the hostname of the VM is still
If i add
If i remove the user CloudInit file
On strange thing i found. When dumping the CloudInit config from the VM via
Anyway, i don't know how to set the hostname of the VM correctly. Not sure if this is a bug or if i am missing something here.
Content of
Content of
VM Configuration
Proxmox Version:
As basis i use the CloudImage
jammy-server-cloudimg-amd64.img
of Ubuntu from https://cloud-images.ubuntu.com/jammy/current/I have two CloudInit files, one for user and one for vendor (see below), which both get added to the template. The template gets created with the following steps:
Bash:
#!/bin/bash
qm create 800001 --name ubuntu-2204-cloud-init --numa 0 --ostype l26 --cores 2 --sockets 1 --memory 2048 -net0 virtio,bridge=vmbr100,firewall=1
qm importdisk 800001 /mnt/pve/nas02-templates/template/iso/jammy-server-cloudimg-amd64.img nas02-images --format=qcow2
qm set 800001 --scsihw virtio-scsi-pci --scsi0 nas02-images:800001/vm-800001-disk-0.qcow2
qm resize 800001 scsi0 50G
qm set 800001 --boot c --bootdisk scsi0
qm set 800001 --serial0 socket --vga serial0
qm set 800001 --ide2 nas02-images:cloudinit
qm set 800001 --agent enabled=1
qm set 800001 --cicustom "user=nas02-templates:snippets/cloudinit-user.yml,vendor=nas02-templates:snippets/cloudinit-vendor.yml"
qm template 800001
Afterwards i clone my VM in the Proxmox GUI from the template created with for example the following options:
- VM ID: 100044
- Name: derufin --> this should be the hostname
- Resource Pool: test-VMs
- Mode: Full Clone
- Target Storage: nas02-images-ssd
- Format: qcow2
- DNS domain: domain.info
- DNS servers: 172.16.100.10
- IP Config (net0)
- IPv4/CIDR: 172.16.100.44/22
- Gateway (IPv4): 172.16.100.1
cloudinit-user.yml
.When starting the VM everything get's set as expected, but the hostname of the VM is still
ubuntu
and not derufin
!If i add
hostname: derufin
to either of my two CloudInit files, the hostname get's set accordingly. But for obvious reasons i do not want to set a hostname in a template!If i remove the user CloudInit file
cloudinit-user.yml
from the template, the hostname get's set correctly, but then there is no user to log in with.On strange thing i found. When dumping the CloudInit config from the VM via
qm cloudinit dump 100044 user
is, that the hostname, manage_etc_hosts and fqdn is found here in the user-configuration. Why is this in user? Shouldn't that be part of network or meta?
YAML:
#cloud-config
hostname: derufin
manage_etc_hosts: true
fqdn: derufin.domain.info
chpasswd:
expire: False
users:
- default
package_upgrade: true
Anyway, i don't know how to set the hostname of the VM correctly. Not sure if this is a bug or if i am missing something here.
Content of
cloudinit-user.yml
:
YAML:
#cloud-config
disable_root: true
chpasswd:
expire: false
groups: mygroup
users:
# - default
- name: myuser
primary_group: mygroup
lock_passwd: false
passwd: $6$C/JR12t/ia5qRYcy$CDhsc.T5rEkvlnaofABfYzwuJ7VH.1RQWy63iRVrbSiljnPh.myDQcDGlzisZQlLXwNSxDKeJJL1wjhoAWD1d0/
shell: /bin/bash
ssh-authorized-keys:
- ssh-rsa AAAAsomekeygarble my.user@domain.info
groups:
- mygroup
- adm
sudo:
- "ALL=(ALL:ALL) ALL"
runcmd:
- 'groupmod --gid 1000 mygroup'
- 'usermod --comment "My User" myuser'
- 'usermod --uid 1000 myuser'
- 'usermod --gid 1000 myuser'
Content of
cloudinit-vendor.yml
:
YAML:
#cloud-config
manage_etc_hosts: true
# locale: de_DE.UTF-8
timezone: Europe/Berlin
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
- qemu-guest-agent
- nfs-common
# - postfix
- ntp
- lynx
# - landscape-client
- apt-transport-https
VM Configuration
/etc/pve/qemu-server/100044.conf
:
YAML:
agent: enabled=1
boot: c
bootdisk: scsi0
cicustom: user=nas02-templates:snippets/cloudinit-user.yml,vendor=nas02-templates:snippets/cloudinit-vendor.yml
cores: 2
ide2: nas02-images-ssd:100044/vm-100044-cloudinit.qcow2,media=cdrom,size=4M
ipconfig0: ip=172.16.100.44/22,gw=172.16.100.1
memory: 2048
meta: creation-qemu=6.2.0,ctime=1654253465
name: derufin
nameserver: 172.16.100.10
net0: virtio=BA:F3:9E:CC:3B:9F,bridge=vmbr100,firewall=1
numa: 0
ostype: l26
scsi0: nas02-images-ssd:100044/vm-100044-disk-0.qcow2,size=50G
scsihw: virtio-scsi-pci
searchdomain: domain.info
serial0: socket
smbios1: uuid=f2907c6c-22e8-4ed6-99f1-924a1cb666a1
sockets: 1
vga: serial0
vmgenid: 1e457e02-041e-4056-8ab7-7e63d2d1567b
Proxmox Version:
Code:
proxmox-ve: 7.2-1 (running kernel: 5.15.35-1-pve)
pve-manager: 7.2-4 (running version: 7.2-4/ca9d43cc)
pve-kernel-5.15: 7.2-3
pve-kernel-helper: 7.2-3
pve-kernel-5.13: 7.1-9
pve-kernel-5.4: 6.4-7
pve-kernel-5.3: 6.1-6
pve-kernel-5.15.35-1-pve: 5.15.35-3
pve-kernel-5.15.30-2-pve: 5.15.30-3
pve-kernel-5.13.19-6-pve: 5.13.19-15
pve-kernel-5.13.19-5-pve: 5.13.19-13
pve-kernel-5.13.19-4-pve: 5.13.19-9
pve-kernel-5.13.19-3-pve: 5.13.19-7
pve-kernel-5.13.19-2-pve: 5.13.19-4
pve-kernel-5.13.19-1-pve: 5.13.19-3
pve-kernel-5.4.143-1-pve: 5.4.143-1
pve-kernel-5.4.140-1-pve: 5.4.140-1
pve-kernel-5.3.18-3-pve: 5.3.18-3
ceph-fuse: 14.2.21-1
corosync: 3.1.5-pve2
criu: 3.15-1+pve-1
glusterfs-client: 9.2-1
ifupdown: 0.8.36+pve1
ksm-control-daemon: 1.4-1
libjs-extjs: 7.0.0-1
libknet1: 1.22-pve2
libproxmox-acme-perl: 1.4.2
libproxmox-backup-qemu0: 1.3.1-1
libpve-access-control: 7.2-1
libpve-apiclient-perl: 3.2-1
libpve-common-perl: 7.2-2
libpve-guest-common-perl: 4.1-2
libpve-http-server-perl: 4.1-2
libpve-storage-perl: 7.2-4
libqb0: 1.0.5-1
libspice-server1: 0.14.3-2.1
lvm2: 2.03.11-2.1
lxc-pve: 4.0.12-1
lxcfs: 4.0.12-pve1
novnc-pve: 1.3.0-3
proxmox-backup-client: 2.2.1-1
proxmox-backup-file-restore: 2.2.1-1
proxmox-mini-journalreader: 1.3-1
proxmox-widget-toolkit: 3.5.1
pve-cluster: 7.2-1
pve-container: 4.2-1
pve-docs: 7.2-2
pve-edk2-firmware: 3.20210831-2
pve-firewall: 4.2-5
pve-firmware: 3.4-2
pve-ha-manager: 3.3-4
pve-i18n: 2.7-2
pve-qemu-kvm: 6.2.0-8
pve-xtermjs: 4.16.0-1
qemu-server: 7.2-3
smartmontools: 7.2-pve3
spiceterm: 3.2-2
swtpm: 0.7.1~bpo11+1
vncterm: 1.7-1
zfsutils-linux: 2.1.4-pve1
Last edited: