Set $(hostname) in /etc/hosts during node spinup 76/64776/1
authorAnil Belur <abelur@linuxfoundation.org>
Thu, 26 Oct 2017 22:05:48 +0000 (08:05 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Thu, 26 Oct 2017 22:05:48 +0000 (08:05 +1000)
Remove the line where we add $(hostname) into /etc/hosts
from the packer provision scripts, since the node name
is obtained during spinup and not during image build time.

Update the Jenkins startup scripts so that the $(hostname)
is updated into /etc/hosts file.

Note this workaround is required only for Ubuntu flavour.

Change-Id: Ia1822426a9c61456cf7b07831289244f103f9d39
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
jenkins-scripts/mininet-ubuntu.sh
jenkins-scripts/ubuntu-docker-ovs.sh
packer/provision/baseline.sh

index 0b925bb29b7b1285db0b50427cf6a90483398c29..7f0cd569ef76c7f4bed431f669c4d8b37ca3a4f6 100755 (executable)
@@ -8,3 +8,9 @@ EOF
 
 # disable the firewall
 /bin/bash ./disable_firewall.sh
+
+# Add 'hostname' into /etc/hosts during node spinup time to avoid sudo returning
+# an 'unable to resolve host' message or some Java API's returning an unknown
+# host exception. The workaround on adding "myhostname" into /etc/nss-switch.conf
+# does not work on Ubuntu flavours.
+sed -i "/127.0.0.1/s/$/\t$(hostname)/" /etc/hosts
index b4e0207e4566f91830e52d9b9d60f574cb41b294..743255b6975c2575f00207d485e7411f14f7b767 100755 (executable)
@@ -6,6 +6,12 @@ Defaults:jenkins !requiretty
 jenkins     ALL = NOPASSWD: ALL
 EOF
 
+# Add 'hostname' into /etc/hosts during node spinup time to avoid sudo returning
+# an 'unable to resolve host' message or some Java API's returning an unknown
+# host exception. The workaround on adding "myhostname" into /etc/nss-switch.conf
+# does not work on Ubuntu flavours.
+sed -i "/127.0.0.1/s/$/\t$(hostname)/" /etc/hosts
+
 # Do the final install of OVS that the has to be done at boot time for
 # some reason due to how the snapshots keep behaving.
 dpkg --install /root/openvswitch-datapath-dkms* && \
index c1ce0bbaeab85be7b614808827a8626c5e1a1806..78e3b64a87c1a3c3edeb0fd4aeaa86c8be385fa4 100644 (file)
@@ -277,9 +277,6 @@ Dpkg::Options {
 
 EOF
 
-    # Add hostname to /etc/hosts to fix 'unable to resolve host' issue with sudo
-    sed -i "/127.0.0.1/s/$/ $(hostname)/" /etc/hosts
-
     echo "---> Updating operating system"
 
     # add additional repositories