Filippo Giunchedi has uploaded a new change for review.

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

Change subject: puppet: hook for easy pushing of branches from anywhere
......................................................................

puppet: hook for easy pushing of branches from anywhere

The idea is to be able to push a branch (e.g. for testing) from your local
machine into a puppet master hosted in labs. Due to the way git works this
isn't straightforward as "git push -f labs_host" because pushing to a
non-bare repository is not supported.

The best compromise I found is to have a bare repository hosted somewhere (e.g.
your /home in the labs instance) and push to that, which in turn will
automatically update the canonical repo in /var/lib/git/operations/puppet via
this hook.

So in practice this is the setup on the labs host:

  cd ~
  git clone --bare --no-hardlinks /var/lib/git/operations/puppet/ puppet.git
  install -m755 
/var/lib/git/operations/puppet/modules/puppet/files/self-master-post-receive 
puppet.git/hooks/post-receive

and on the local host add the relevant remote:

  git remote add labs_host ssh://$LABS_HOSTNAME/~/puppet.git

then to test a puppet change in your labs puppet master from your local host
you can:

  git push -f labs_host HEAD:production

and wait for puppet to run.

Change-Id: Ia300ab64b3a6fff3be8358bff6840ee856141602
---
A modules/puppet/files/self-master-post-receive
1 file changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/20/159720/1

diff --git a/modules/puppet/files/self-master-post-receive 
b/modules/puppet/files/self-master-post-receive
new file mode 100644
index 0000000..edd7268
--- /dev/null
+++ b/modules/puppet/files/self-master-post-receive
@@ -0,0 +1,13 @@
+#!/bin/sh
+# used to update the instance puppet master repository from a repository in a
+# non-canonical location, e.g. to push branches for testing
+
+# this dance is necessary because git doesn't like pushing to non-bare
+# repositories (the index gets confused)
+set -e
+set -u
+
+source_dir=$PWD
+cd /var/lib/git/operations/puppet
+sudo git fetch $source_dir
+sudo git checkout FETCH_HEAD

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia300ab64b3a6fff3be8358bff6840ee856141602
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org>

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

Reply via email to