Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/115342

Change subject: Add a script that updates labs instances after migration.
......................................................................

Add a script that updates labs instances after migration.

This script will do nothing in tampa.  Once an instance
is moved to eqiad the script will run once, then never again.

It fixes resolv.conf and puppet for the new dc.

Change-Id: I7aed392e9935ff26a5f61df6d7487d474d02a731
---
A files/labs/migrate/migrate_firstboot.sh
A files/labs/migrate/rc.local
M manifests/role/labs.pp
3 files changed, 48 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/42/115342/1

diff --git a/files/labs/migrate/migrate_firstboot.sh 
b/files/labs/migrate/migrate_firstboot.sh
new file mode 100755
index 0000000..7fd8d46
--- /dev/null
+++ b/files/labs/migrate/migrate_firstboot.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -x
+
+FLAG="/var/log/migratefirstboot.log"
+if [ ! -f $FLAG ]; then
+    ip=`hostname -i`
+    if ( echo $ip | grep -qG "10.68." ); then
+        echo "Detected first boot in eqiad."
+
+        echo "Updating puppet host and cert"
+        id=`curl http://169.254.169.254/1.0/meta-data/instance-id 2> /dev/null`
+        idfqdn=${id}.eqiad.wmflabs
+        master=virt1000.wikimedia.org
+        sed -i "s/virt0.wikimedia.org/${master}/g" /etc/puppet/puppet.conf
+        sed -i "s/^certname = .*$/certname = ${idfqdn}/g" 
/etc/puppet/puppet.conf
+        find /var/lib/puppet -type f -print0 |xargs -0r rm
+
+        echo "forcing a puppet run"
+       puppet agent --onetime --verbose --no-daemonize --no-splay --show_diff 
--waitforcert=10
+
+        echo "Marking our work as done and rebooting"
+        touch $FLAG
+    fi
+fi
diff --git a/files/labs/migrate/rc.local b/files/labs/migrate/rc.local
new file mode 100644
index 0000000..a59c359
--- /dev/null
+++ b/files/labs/migrate/rc.local
@@ -0,0 +1,3 @@
+#!/bin/sh -e
+/root/migrate_firstboot.sh
+exit 0
diff --git a/manifests/role/labs.pp b/manifests/role/labs.pp
index 2568a73..ba02805 100644
--- a/manifests/role/labs.pp
+++ b/manifests/role/labs.pp
@@ -112,5 +112,26 @@
         }
 
     }
+
+    # Temporary hacks for migration to eqiad:
+    file { '/root/migrate_firstboot.sh':
+        ensure => present,
+        owner => root,
+        group => root,
+        mode => 0755,
+        source => 'puppet:///files/labs/migrate/migrate_firstboot.sh',
+    }
+    file { '/etc/rc.local':
+        ensure => present,
+        owner => root,
+        group => root,
+        mode => 0755,
+        source => 'puppet:///files/labs/migrate/rc.local',
+    }
+
+    file { '/root/migrate_firstboot.sh':
+        ensure => directory, owner => 'root', group => 'root', mode => '0755',
+        require => File['/public'],
+    }
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7aed392e9935ff26a5f61df6d7487d474d02a731
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <abog...@wikimedia.org>

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

Reply via email to