Created
March 26, 2012 03:29
-
-
Save nibalizer/2202658 to your computer and use it in GitHub Desktop.
puppetsync shell script
This file contains 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: GITOLITE_DIR/repositories/puppet.git/hooks/post-receive | |
puppetsync() | |
{ | |
ssh $SSH_ARGS "$PUPPETMASTER" "$SYNC_COMMAND" \ | |
--branch "$BRANCH" \ | |
--repository "$REPO" \ | |
--deploy "$DEPLOY" \ | |
$DELETE | |
} | |
set_common() | |
{ | |
REPO="git@GITOLITE:puppet.git" | |
SYNC_COMMAND="/usr/local/bin/puppetsync" | |
SSH_ARGS="-i $HOME/git/.ssh/git@GITOLITE" | |
} | |
set_puppetmaster(){ | |
DEPLOY="/usr/local/etc/puppet/environments" | |
PUPPETMASTER="puppet@PUPPETMASTER" | |
} | |
set_otherpuppetmaster(){ | |
DEPLOY="/usr/local/etc/puppet/environments" | |
PUPPETMASTER="puppet@PUPPETMASTER" | |
} | |
set_commonwhile read oldrev newrev refname; do BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'` | |
[ "$newrev" -eq 0 ] 2> /dev/null && DELETE='--delete' || DELETE='' | |
set_puppetmaster; puppetsync | |
#set_otherpuppetmaster; puppetsync | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment