From 568978d76fff65da6879cff285c6e4eb22a94c4e Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Tue, 25 Aug 2015 11:47:19 -0700 Subject: [PATCH] pulling some stuff from npwalker/control-repo --- Puppetfile | 28 ++++++++++++++++++++++++++++ environment.conf | 8 ++++++++ hieradata/common.yaml | 2 ++ scripts/config_version.rb | 17 +++++++++++++++++ scripts/config_version.sh | 7 +++++++ 5 files changed, 62 insertions(+) create mode 100644 Puppetfile create mode 100644 environment.conf create mode 100644 hieradata/common.yaml create mode 100755 scripts/config_version.rb create mode 100755 scripts/config_version.sh diff --git a/Puppetfile b/Puppetfile new file mode 100644 index 0000000..5691668 --- /dev/null +++ b/Puppetfile @@ -0,0 +1,28 @@ +forge "http://forge.puppetlabs.com" + +# Modules from the Puppet Forge +# Note the versions are all set to :latest but after you've +# installed you should change them to the exact version you want +mod "puppetlabs/inifile", :latest +mod "puppetlabs/stdlib", :latest +mod "puppetlabs/concat", :latest + +#An example of using a specific forge module version instead of latest +#Notice the addition of single quotes +#mod "puppetlabs/inifile", '1.3.0' + +# Modules from Github using various references +# Further examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples +# update the tag to the most current release when implementing +#mod 'hiera', +# :git => 'https://github.com/hunner/puppet-hiera', +# :tag => '1.3.1' + +#mod 'notifyme', +# :git => 'git://github.com/glarizza/puppet-notifyme', +# :ref => '50c01703b2e3e352520a9a2271ea4947fe17a51f' + +#mod 'profiles', +# :git => 'git://github.com/glarizza/puppet-profiles', +# :ref => '3611ae4253ff01762f9bda1d93620edf8f9a3b22' + diff --git a/environment.conf b/environment.conf new file mode 100644 index 0000000..6d60708 --- /dev/null +++ b/environment.conf @@ -0,0 +1,8 @@ +modulepath = modules:site:$basemodulepath +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. +# https://docs.puppetlabs.com/puppetserver/1.0/release_notes.html#new-feature-admin-api-for-refreshing-environments +# https://docs.puppetlabs.com/puppet/3.7/reference/environments_configuring.html#environmenttimeout +environment_timeout = 0 diff --git a/hieradata/common.yaml b/hieradata/common.yaml new file mode 100644 index 0000000..2baa62b --- /dev/null +++ b/hieradata/common.yaml @@ -0,0 +1,2 @@ +--- +message: "This node is using common data" diff --git a/scripts/config_version.rb b/scripts/config_version.rb new file mode 100755 index 0000000..52f32c5 --- /dev/null +++ b/scripts/config_version.rb @@ -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 diff --git a/scripts/config_version.sh b/scripts/config_version.sh new file mode 100755 index 0000000..543ec26 --- /dev/null +++ b/scripts/config_version.sh @@ -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 $1/$2/.git rev-parse HEAD +fi