fix a bug, where the maas host was hardcoded incorrectly and correct output when no compute hosts present

Change-Id: Ida3b090328ab9be63ef25a726ba7aca674e2f48a
diff --git a/roles/head-node/files/pod-inventory b/roles/head-node/files/pod-inventory
index 29571de..89c368f 100644
--- a/roles/head-node/files/pod-inventory
+++ b/roles/head-node/files/pod-inventory
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-maas login cord http://10.2.0.1/MAAS/api/1.0 '{{ apikey.stdout }}' > /dev/null
+maas login cord http://localhost/MAAS/api/1.0 '{{ apikey.stdout }}' > /dev/null
 NODES=$(maas cord nodes list | jq '.[].hostname' | sed -e 's/"//g')
 maas logout cord
 
@@ -15,9 +15,11 @@
     "hosts" : [
 EO_HEAD
 
-for i in $(echo $NODES | sed -e 's/\([a-zA-Z0-9_-.]*\)/"\1"/g' -e 's/ /, /g'); do
-echo "      $i"
-done
+if [ ! -z "$NODES" ]; then
+  for i in $(echo $NODES | sed -e 's/\([a-zA-Z0-9_-.]*\)/"\1"/g' -e 's/ /, /g'); do
+    echo "      $i"
+  done
+fi
 
 cat << EO_TAIL
     ]