>
> sort of git hook, but I'm not sure how to implement it efficiently and
> securely with a shared repository on another server.  I went looking

I thought about this, but abandoned it.  Hooks in git have to be  
configured on each repository, since there is no central repository,  
as such.

I keep the three different environments on different branches, and use  
a script to update /etc/puppet from the repository every ten minutes.  
You have to clone the repository manually to do the initial config but  
after that it more or less runs itself. I run it as the puppet user.

Darrell


#!/bin/sh
#
# we do this so we get the right ssh keyfile
HOME=`/usr/bin/getent passwd puppet | /bin/cut -d: -f6`

localrepo=/etc/scripts
repopuppetdir=${localrepo}/puppet

puppetdir=/etc/puppet

gitrepo='[EMAIL PROTECTED]:XXXXX.git'

git=/usr/bin/git
rsync=/usr/bin/rsync

puppetmasterpid=/var/run/puppet/puppetmasterd.pid

environments="production staging"

if [ ! -d ${localrepo} ]; then
         if [ -w `dirname ${localrepo}` ]; then
                 $git clone -q $gitrepo $localrepo
                 status=$?
                 if [ $status -ne '0' ]; then
                         echo "git clone failed in $0"
                         echo "removing stray ${localrepo}"
                         /bin/rm -rf ${localrepo}
                         exit 1
                 fi
                 #
                 # just to be safe
                 chown -R puppet:puppet $localrepo
                 chmod 750 $localrepo
         else
                 echo "could not greate git clone for puppet in $0"
                 exit 1
         fi

else
         # repository seems to exist, let's update it
         # apparently -q to git doesn't mean that it won't tell us
         # that nothing's different. wankers.
         cd $localrepo && $git checkout -q master > /dev/null
         status=$?
         if [ $status -ne '0' ]; then
                 echo "$0 : switching to master failed. bailing"
                 exit 1
         fi

         cd $localrepo && $git pull -q -n > /dev/null 2>&1
         status=$?
         if [ $status -ne '0' ]; then
                 echo "bailing: git pull failed in $0"
                 exit 1
         fi
fi

# master gets synced to development branch
$rsync --exclude=ssl --exclude=scripts -aq --delete ${repopuppetdir}/ / 
etc/puppet/development

for env in $environments; do
  cd $localrepo && $git checkout -q $env
  cd $localrepo && $git pull -q -n > /dev/null 2>&1
  $rsync --exclude=ssl --exclude=scripts -aq --delete $ 
{repopuppetdir}/ /etc/puppet/${env}

status=$?

if [ $? -ne "0" ]; then
         echo "rsync failed to sync branch $env in puppet repository  
on `hostname` - please investigate"

fi
done


$git checkout -q master

exit 0


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to