Don't rely on lsb_release for hosts template write
authorSteve Baker <sbaker@redhat.com>
Tue, 6 Dec 2016 23:06:44 +0000 (23:06 +0000)
committerSteve Baker <sbaker@redhat.com>
Thu, 8 Dec 2016 20:09:26 +0000 (20:09 +0000)
This is problematic for the containerised heat-agents, lsb_release has
to be bind-mounted in, and atomic host doesn't even have lsb_release
installed.

Instead just write to every /etc/cloud/templates/hosts.*.tmpl file.

Change-Id: If2aab7e9b1e03aa657baf1c33aa4392ef7044075

scripts/hosts-config.sh

index 4826d61..f456b31 100755 (executable)
@@ -30,17 +30,9 @@ write_entries() {
 }
 
 if [ ! -z "$hosts" ]; then
-    # cloud-init files are /etc/cloud/templates/hosts.OSNAME.tmpl
-    DIST=$(lsb_release -is | tr -s [A-Z] [a-z])
-    case $DIST in
-        fedora|redhatenterpriseserver)
-            name="redhat"
-            ;;
-        *)
-            name="$DIST"
-            ;;
-    esac
-    write_entries "/etc/cloud/templates/hosts.${name}.tmpl" "$hosts"
+    for tmpl in /etc/cloud/templates/hosts.*.tmpl ; do
+        write_entries "$tmpl" "$hosts"
+    done
     write_entries "/etc/hosts" "$hosts"
 else
     echo "No hosts in Heat, nothing written."