Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 1.92 KB

README.textile

File metadata and controls

60 lines (46 loc) · 1.92 KB

Puppet-Sync

This project provides a script to synchronize you manifests from a GIT
repository to your Puppet master.

Usage

   puppet-sync -b BRANCH [options]
    -b, --branch BRANCH              Mandatory, specify the git branch to clone.
    -t, --tmp DIR                    Specify the temporary directory.
    -d, --destination DIR            Specify the directory which will be deploy to.
    -r, --repository URL             Git url to the repository.
    -p, --passenger                  Restart apache/passenger instead of puppetmaster.
    Common options:
    -V, --version                    Display the script version.
    -v, --verbose                    Be more verbose.
    -h, --help                       Show this message

To sync a specific branch, to specific location, from a specific repository run the
script with the following arguments:

  puppet-sync --branch master \
              --destination /etc/puppet/environments \
              --repository ssh+git://git/puppet.git

Git Hook

I usually call this script from a GIT hook. If your GIT repository is located
on a different server as your Puppet master, you will need to ensure that
a certain user can login to your Puppet server, without manual interactions.

  # create a puppet-sync user
  useradd puppet-sync

  # change to the user
  sudo su - puppet-sync

  # generate a ssh key
  ssh-keygen -t rsa -b 4096

  # copy the ssh key to your puppet master (where you have already
  # created the puppet-sync user too ;-))
  scp ~puppet-sync/.ssh/id_rsa.pub puppet:/home/puppet-sync/.ssh

Now you need to add the following line to the Git hook file:

   # /git/puppet.git/hooks/post-update
   #
   branch=`echo $1 | awk -F/ {'print $3'}`
   sudo -u puppet-sync ssh puppet /usr/local/bin/puppet-sync --branch \$branch -r ssh+git://git/puppet.git"

   exec git-update-server-info" >> /git/puppet.git/hooks/post-update