Search code examples
openstack

How do I have hostnames with full stop in Openstack Heat templates?


I am trying to set the hostname to be the full DNS name of a server, but if I include a full stop it seems to be cut from the end.

This is how I am setting the hostname:

properties:
      name: sample-name.domain.com

However, this gives a hostname of sample-name. The full name shows up correctly in the Instances list.


Solution

  • I looked into the /var/log/cloud-init.log and I see that the hostname is set to "sample-name" irrespective of whether you set the name to "sample-name.domain.com" or "sample-name" in the properties.

    So, we can set the hostname using "user_data" in heat template as below:

    user_data:
                #!/bin/bash
                sudo bash -c "echo 'sample-name.domain.com' > /etc/hostname"
                sudo bash -c "hostname sample-name.domain.com"