Closed jashmenn closed 14 years ago
in my build_centos.sh I have made the follwoing change to set the hostname:
Replaced this block:
if [ -z hostname
]; then
hostname "poolparty"
echo poolparty > /etc/hostname
/etc/init.d/hostname.sh start 2>/dev/null
fi
With:
PUBLIC_IP=/usr/local/bin/ec2-metadata -o|cut -d " " -f 2
echo $PUBLIC_IP>/tmp/ip_addr
HOST_NOT_SET=hostname|cut -d "-" -f 1
if [ $HOST_NOT_SET = "domU" ]; then
hostname $HOSTNAME
sed -i.bak s/localhost.localdomain/$HOSTNAME/g /etc/sysconfig/network
echo "127.0.0.1 $HOSTNAME localhost.localdomain localhost" >/etc/hosts
fi
While I have ec2-metadata installed on my images, you can also use the "curl http://169.254.169.254/latest/meta-data/local-ipv4" method
The main problem is this is an instance by instance setup. I am still trying to figure out how to do a cloud-start, and ether explicitly assign from an array possibly, or use a pattern (i.e. cloud-start 5 instances, with the hostnames webX, webX+1, etc)
this issue is a placeholder for notes on using centos and more restrictive environments.