Update config_version to use a script that does not require git

The config_version now uses a script that will do one of two
things:

1. call config_version.rb which uses rugged to find the information
about the latest commit if PE is on version 2015.2 or newer

2. make a call to git if the PE version is less than 2015.2
This commit is contained in:
Nick Walker 2015-08-03 17:05:06 -07:00
parent 437433ff44
commit f5cb1fa757
3 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,5 @@
modulepath = modules:site:$basemodulepath
config_version = '/usr/bin/git --git-dir $confdir/environments/$environment/.git rev-parse HEAD'
config_version = 'scripts/config_version.sh $environmentpath $environment'
# Environment timeout should be set to unlimited. When set to zero it is less performant.
# When code is deployed the admin API of puppetserver should be used to force a refresh of code from disk.

17
scripts/config_version.rb Normal file
View File

@ -0,0 +1,17 @@
require 'rugged'
environmentpath = ARGV[0]
environment = ARGV[1]
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
head = repo.head
#sha1 hash of the newest commit
head_sha = head.target_id
#the commit message associated the newest commit
commit = repo.lookup(head_sha)
#add something to find the remote url
puts head_sha

View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ -e /opt/puppetlabs/server/pe_version ]
then
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
else
/usr/bin/git --git-dir $codedir/environments/$environment/.git rev-parse HEAD
fi