Skip to content

Instantly share code, notes, and snippets.

@nibalizer
Created March 26, 2012 03:29
Show Gist options
  • Save nibalizer/2202658 to your computer and use it in GitHub Desktop.
Save nibalizer/2202658 to your computer and use it in GitHub Desktop.
puppetsync shell script
#!/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