FQDN in SET_HOSTNAME

I was just looking for a solution to pass Sunstone ‘VM name’ FQDN to VM and found this thread. For anyone that may need it here is my way:

  1. Add custom script in Files with content:
    #!/bin/bash
    [ -n “$SET_HOSTNAME” ] && hostnamectl set-hostname ${SET_HOSTNAME}

  2. Enable your custom script in VM template - Context - Files
    Add it to ‘Init scripts’ list too

  3. in VM template - Context - Custom vars add
    SET_HOSTNAME = $NAME

  4. Create VM in Sunstone and set VM name to FQDN ‘host.domain.com

After logging into new VM ‘hostnamectl’ will show FQDN in ‘Static hostname’ field

Without the script your hostname will be truncated to just ‘host’