[Openstack] Hostname into instance via Cloud-Init

Ryan Brown rybrown at redhat.com
Tue Mar 31 12:26:36 UTC 2015


On 03/31/2015 01:51 AM, James Buckett wrote:
> 
> Hello OpenStack Community.
> .
> I would like to ask for comments on how to insert a hostname into to an
> instance using cloud-init.
> .
> I am using a pool of assign IP addresses that have hostnames assigned in
> DNS.
> .
> Thanks In Advance.
> .
> James Buckett
> IBM Cloud Consultant
> IBM Cloud Software Services
> Mobile:  +61-434-078-044
> e-Mail: james.buckett at au1.ibm.com

It depends (tm).

If the hostname is in the instance metadata then you can just call the
metadata service in your init script and put the result in /etc/hostname.

If it's more like how AWS makes a hostname (1-2-3-4-ec2-internal)
programmatically from an IP address, then you can just get the IP
address and manipulate it with awk/sed/whatever to the format you like.

-- 
Ryan Brown / Software Engineer, Openstack / Red Hat, Inc.




More information about the Openstack mailing list