Monthly Archives: July 2015

Print git hash during puppet run

So here a little trick that I implemented @customer

During each puppet run, the git commit hash of the puppet manifest
being applied in printed on in the logs instead of a timestamp:

# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for
Info: Applying configuration version ’38f861974ef7041752c0051cfbca676544dc1cef’
Notice: Finished catalog run in 9.78 seconds

To achieve that, I’m just storing the git hash in a file
(something like “echo $GIT_COMMIT > .gitversion”) when building the package in jenkins
and then deploying it in the rpm.

In the puppet server configuration I have the following configuration

config_version = /bin/cat $confdir/environments/$environment/.gitversion