[lxc-devel] [PATCH] hooks/ubuntu-cloud-prep: add hostname to meta-data
Scott Moser
smoser at ubuntu.com
Thu Aug 22 13:15:47 UTC 2013
prior to my enabling of the clone hook, the setting of the hostname
was being done by writing to /etc/hostname. Instead of relying on that
we're now writing 'local-hostname' into the metadata for the instance.
cloud-init then reads this and sets the hostname properly.
The one caveat is that setting of the hostname then occurs after
the initial dhcp, so the hostname sent in the dhcp request would be
the original one.
Should this prove problematic (possibly for avahi dns) we can revert
to explicitly writing the hostname into /etc/hostname as well.
---
hooks/ubuntu-cloud-prep | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hooks/ubuntu-cloud-prep b/hooks/ubuntu-cloud-prep
index c4c3620..725c63a 100755
--- a/hooks/ubuntu-cloud-prep
+++ b/hooks/ubuntu-cloud-prep
@@ -49,8 +49,8 @@ prep() {
fi
local cur="" next=""
- local userdata="" hostid="" authkey="" locales=1 cloud=0 name=""
- local create_etc_init=0
+ local userdata="" hostid="" authkey="" locales=1 cloud=0
+ local create_etc_init=0 name="ubuntucloud-lxc"
while [ $# -ne 0 ]; do
cur="$1"; next="$2";
@@ -110,6 +110,9 @@ prep() {
echo "instance-id: lxc-$hostid" > "$seed_d/meta-data" ||
{ error "failed to write to $seed_d/meta-data"; return 1; }
+ echo "local-hostname: $name" >> "$seed_d/meta-data" ||
+ { error "failed to write to $seed_d/meta-data"; return 1; }
+
if [ -n "$authkey" ]; then
{
echo "public-keys:" &&
--
1.8.3.2
More information about the lxc-devel
mailing list