Fix for UnKnownHost exception
[releng/builder.git] / packer / provision / baseline.sh
index 2fa3473766d0aa1316776b60be5c0716141625e6..c1ce0bbaeab85be7b614808827a8626c5e1a1806 100644 (file)
@@ -440,6 +440,11 @@ all_systems() {
             echo "No extra steps for $FACTER_OS"
         ;;
     esac
+
+    # Update /etc/nss-switch.conf to map hostname with IP instead of using `localhost`
+    # from /etc/hosts which is required by some of the Java API's to avoid
+    # Java UnknownHostException: "Name or service not known" error.
+    sed -i "/^hosts:/s/$/ myhostname/" /etc/nsswitch.conf
 }
 
 echo "---> Attempting to detect OS"