Setting VM Hostname

How do you set the hostname for a VM when it is deployed?

Till now nothing but you can create a custom context
for more information check this on github


for centos 7 :

Ok, how would I set it up? Here is what I have?

CONTEXT=[INIT_SCRIPTS=“05-hostname”,NETWORK=“YES”,SSH_PUBLIC_KEY=“$USER[SSH_PUBLIC_KEY]”]
CPU=“1”
DISK=[IMAGE=“Debian-7-kvm”,IMAGE_UNAME=“oneadmin”]
GRAPHICS=[LISTEN=“0.0.0.0”,TYPE=“VNC”]
HYPERVISOR=“kvm”
LOGO=“images/logos/debian.png”
MEMORY=“512”
NIC=[NETWORK=“GT-100”,NETWORK_UNAME=“oneadmin”]
OS=[ARCH=“x86_64”,BOOT=“hd”]
VCPU=“4”

with basic contextualization of a VM, we set the hostname using this addition to a template:

CONTEXT=[DNS_HOSTNAME="YES"]

Of course, you need to pre-define the range of hostnames in your DNS server(s) for this to work properly

Thanks, I got it working with set_hostname=$name

2 Likes

Hi @debian112 what would be the outcome if the vm name is changed from the GUI. would the vm name also changes at the OS level on next reboot?