FQDN in SET_HOSTNAME

Javi Fontán opennebula@discoursemail.com writes:

I’m thinking that setting FQDN is useful but I’m not sure how to implement this.

  • Remove “.” restriction from SET_HOSTNAME
  • Add SET_DOMAIN and use it to set the FQDN

I believe that letting use “.” is the most straightforward solution and maybe what people expect.

I agree, an FQDN is related to HOSTNAME and DOMAIN with:

  • HOSTNAME = FQDN.split(“.”)[0]
  • DOMAIN = FQDN.split(“.”).slice(1…-1).join(“.”)

So we can always split SET_HOSTNAME on “.”:

  • set HOSTNAME from first element

  • set DOMAIN from “FQDN.split(“.”).slice(1…-1).join(“.”)” is not an
    empty string

We can use a SET_DOMAIN to define the resolv.conf “domain” and “search”.

Regards.
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6 2AAD CC1E 9E5B 7A6F E2DF

Anything new on this matter ?

I’d made a bunch of patches (for DNS_HOSTNAME=yes) that also modified the splitting.
Will put them online on the weekend so you guys can comment.

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’