Permit injecting entries into /etc/hosts.

We need this for the test-environment machines.

Change-Id: I499607a26e6282a9f37b91989fe6c1821d0cca9d
This commit is contained in:
Robert Collins 2014-01-31 21:06:08 +13:00
parent 9411e027f7
commit b7e470d212
4 changed files with 27 additions and 0 deletions

5
elements/hosts/README.md Normal file
View File

@ -0,0 +1,5 @@
Permit injecting content into /etc/hosts from heat
# Configuration
hosts: '12.3.4 my-host.com'

View File

@ -0,0 +1,2 @@
os-apply-config
os-refresh-config

View File

@ -0,0 +1 @@
{{hosts}}

View File

@ -0,0 +1,19 @@
#!/bin/bash
set -eu
set -o pipefail
# 51 - right after oac as hosts is needed for $justabouteverything.
if [ ! -e /etc/hosts -o ! -e /var/run/hosts.d/tail ]; then
exit 0
fi
if fgrep -f /var/run/hosts.d/tail /etc/hosts; then
exit 0
fi
cp /etc/hosts /var/run/hosts.d/new-hosts
echo >> /var/run/hosts.d/new-hosts
cat /var/run/hosts.d/tail >> /var/run/hosts.d/new-hosts
echo >> /var/run/hosts.d/new-hosts
mv /var/run/hosts.d/new-hosts /etc/hosts