Andrew Bogott has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344656 )

Change subject: bootstrap_vz:  Handle initial hostname a bit better
......................................................................


bootstrap_vz:  Handle initial hostname a bit better

- If hostname resolves to 'localhost' give dhcp a few bumps
   so it has a chance to catch up.
- Explicitly set /etc/hostname so that hostname persists after reboots.
   (I think this was previously handled by cloud-init)

Bug: T160908
Change-Id: I47abf38044088831b6b1a0389f3d81910d2f6937
---
M modules/labs_bootstrapvz/files/firstboot.sh
1 file changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Andrew Bogott: Looks good to me, approved
  Rush: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/modules/labs_bootstrapvz/files/firstboot.sh 
b/modules/labs_bootstrapvz/files/firstboot.sh
index 8349be2..c90e187 100644
--- a/modules/labs_bootstrapvz/files/firstboot.sh
+++ b/modules/labs_bootstrapvz/files/firstboot.sh
@@ -62,6 +62,23 @@
 project=`curl http://169.254.169.254/openstack/latest/meta_data.json/ | sed -r 
's/^.*project_id\": \"//'  | sed -r 's/\".*$//g'`
 ip=`curl http://169.254.169.254/1.0/meta-data/local-ipv4 2> /dev/null`
 hostname=`hostname`
+
+# If we're getting ahead of the dnsmasq config, loop until our hostname is
+#  actually ready for us.
+for run in {1..10}
+do
+    if [ "$hostname" != 'localhost' ]
+    then
+        break
+    fi
+
+    echo `date`
+    echo "Waiting for hostname to return the actual hostname."
+    sleep 1
+    /sbin/dhclient -1
+    hostname=`hostname`
+done
+
 # domain is the last two domain sections, e.g. eqiad.wmflabs
 domain=`hostname -d | sed -r 's/.*\.([^.]+\.[^.]+)$/\1/'`
 
@@ -137,6 +154,7 @@
 EOF
 
 echo "$ip      $fqdn" >> /etc/hosts
+echo $hostname > /etc/hostname
 
 # This is only needed when running bootstrap-vz on
 # a puppetmaster::self instance, and even then

-- 
To view, visit https://gerrit.wikimedia.org/r/344656
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I47abf38044088831b6b1a0389f3d81910d2f6937
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <abog...@wikimedia.org>
Gerrit-Reviewer: Andrew Bogott <abog...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: Rush <r...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to