Created
June 13, 2013 09:51
-
-
Save zipkid/5772556 to your computer and use it in GitHub Desktop.
git hook for remote puppetmaster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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