Make sure hostname has no domain 79/20579/1
authorLusheng Ji <lji@research.att.com>
Wed, 25 Oct 2017 16:13:28 +0000 (12:13 -0400)
committerLusheng Ji <lji@research.att.com>
Wed, 25 Oct 2017 16:13:34 +0000 (12:13 -0400)
In some environments, hostname returns a hostname with a
default domain, e.g novalocal. This domain may conflict
with the dns_domain option setting.  Added a test to strip
off domain if that happens.

Issue-Id: DCAEGEN2-128
Change-Id: Ie4995f542305e465ec11689acccc053f081f2df2
Signed-off-by: Lusheng Ji <lji@research.att.com>
blueprints/centos_vm.yaml-template

index 1211625..aa3bdb4 100644 (file)
@@ -75,6 +75,7 @@ inputs:
       CONSULNAME=consul_${CONSULVER}_linux_amd64
       MYIP=`curl -Ss http://169.254.169.254/2009-04-04/meta-data/local-ipv4`
       MYNAME=`hostname`
+      if [ ! -z "$(echo $MYNAME |grep '.')" ]; then MYNAME="$(echo $MYNAME | cut -f1 -d '.')"; fi
       echo >>/etc/hosts
       echo $MYIP $MYNAME >>/etc/hosts
       mkdir -p /opt/consul/config /opt/consul/data /opt/consul/bin