Skip to content

Instantly share code, notes, and snippets.

@zipkid
Created June 13, 2013 09:51
Show Gist options
  • Save zipkid/5772556 to your computer and use it in GitHub Desktop.
Save zipkid/5772556 to your computer and use it in GitHub Desktop.
git hook for remote puppetmaster
#!/bin/sh
# File: /git/puppet.git/hooks/post-receive
#set -x
REPO="user@gitserver:/srv/git/hieradata.git"
DEPLOY="/somedir/puppet/hieradata"
SSH_ARGS="-i $HOME/.ssh/id_dsa_userkey"
PUPPETMASTER="user@masterserver"
SYNC_COMMAND="/script/git/scripts/puppet-sync"
while read oldrev newrev refname
do
BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'`
if [ "$BRANCH" == "master" ]; then
continue
fi
if [ "$BRANCH" == "production" ]; then
continue
fi
[ "$newrev" -eq 0 ] 2> /dev/null && DELETE='--delete' || DELETE=''
ssh $SSH_ARGS "$PUPPETMASTER" "$SYNC_COMMAND" \
--branch "$BRANCH" \
--repository "$REPO" \
--deploy "$DEPLOY" \
$DELETE
Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment