From 9a3daed8316f7c455b53250217d36172593236a4 Mon Sep 17 00:00:00 2001 From: Lusheng Ji Date: Wed, 25 Oct 2017 12:13:28 -0400 Subject: [PATCH] Make sure hostname has no domain 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 --- blueprints/centos_vm.yaml-template | 1 + 1 file changed, 1 insertion(+) diff --git a/blueprints/centos_vm.yaml-template b/blueprints/centos_vm.yaml-template index 1211625..aa3bdb4 100644 --- a/blueprints/centos_vm.yaml-template +++ b/blueprints/centos_vm.yaml-template @@ -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 -- 2.16.6