Hostname in Cloud-init user data

No, its not possible today. You will need to wrap it around with something. What the wrapper is will depend on how you create your VMs.
You can also file an enhancement request as described here: https://forum.proxmox.com/threads/where-to-post-feature-requests.46317/


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

So I'll have to create a user-data snippet per VM. Would be useful to do this with the PVE API, as others think too: https://forum.proxmox.com/threads/creating-snippets-using-pve-api.54081/
 
Proxmox default user config would look like this:
Code:
qm cloudinit dump 9000 user
#cloud-config
hostname: tmpl
manage_etc_hosts: true
fqdn: tmpl
chpasswd:
  expire: False
users:
  - default
package_upgrade: true

Hostname will be dynamic whenever new VM will be created with certain name specified:
Code:
qm cloudinit dump 100 user
#cloud-config
hostname: foo
fqdn: foo

So you can use cicustom with vendor custom file (instead of user custom file) and keep user custom file for Proxmox:
Code:
# cat 9000.conf
cicustom: vendor=local:snippets/vendor.yaml,network=local:snippets/network.yaml

Although the new problem would with users directive in vendor file. Proxmox adds users directive when ciuser is either no set or set to anything other root. As per cloud-init docs, users and groups module frequency is once per instance so if vendor file has users directive too - vendor users directive won't be executed.
 

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!