Code Monkey home page Code Monkey logo

puppet-sync's Introduction

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]
   puppet-sync -s [options]
    -b, --branch BRANCH     Mandatory; specify the git branch to clone.
    -d, --deploy DIR        Specify the directory to deploy to.
    -D, --delete            Remove the specified branch from the deployment directory.
    -r, --repository URL    Git url for the repository.
    -s, --submodules-enabled SUBMODULES Comma-separated list of submodules to
                                        update. If not specified, all submodules
                                        in the repo will be updated.
    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 \
              --deploy /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.
I use the “puppet” user for this purpose.

  # change to the user and generate a key
  sudo -u puppet ssh-keygen -t rsa -b 4096 -f ~puppet/.ssh/id_rsa

  # copy the public key file to your puppetmaster server (where you have already
  # created the puppet user)
  ssh server 'cat - >> ~puppet/.ssh/authorized_keys' < ~puppet/.ssh/id_rsa.pub

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

  #!/bin/sh
  # File: /git/puppet.git/hooks/post-update

  REPO="[email protected]:puppet.git"
  DEPLOY="/etc/puppet/environments"
  SSH_ARGS="-i /path/to/privatekey"
  PUPPETMASTER="[email protected]"
  SYNC_COMMAND="/usr/local/bin/puppet-sync"

  while read oldrev newrev refname
  do
    BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'`
    [ "$newrev" -eq 0 ] 2> /dev/null && DELETE='--delete' || DELETE=''

    ssh $SSH_ARGS "$PUPPETMASTER" "$SYNC_COMMAND" \
      --branch "$BRANCH" \
      --repository "$REPO" \
      --deploy "$DEPLOY" \
      $DELETE

  done

puppet-sync's People

Contributors

reidmv avatar dpeters avatar sts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.