Git tips

User documentation

Somes tips and tricks for managing Puppet and Puppet modules with Git.


You can catch syntax errors by using commit or update hooks. Use a commit hook to catch errors when comitting to your local workspace. An update hook can be placed on a central repository and will catch errors when pushing to that repository (useful when there are multiple contributors).

The code is here :


Keeping track of local modifications to modules can be a big issue when using many different modules. You can make this task easier by placing the Puppet configuration (ie. /etc/puppet) in a Git repository and clone the various modules as Git submodules :

  1. Create the "superproject" Git repository on your server.
  2. Add the submodules :
    git submodule add <url> <path>
  3. Check out the code :
    git submodule init
  4. Commit your new submodules into the "superproject" repository :
    git add modules/foo modules/bar
    git commit -m "foo, bar: new modules"

That allows your tu use magical commands such as this one, which will cycle through all your submodules and show any local changes (remove --name-status to show actual diff) :

git submodule foreach --recursive git diff --name-status

References :