Skip to content

Instantly share code, notes, and snippets.

@gsarjeant
gsarjeant / gist:8697898
Created January 29, 2014 21:48
$environment in hiera_config in PE 3.2
== Static hiera_config ==
[root@master puppet]# grep hiera puppet.conf
hiera_config = /etc/puppetlabs/puppet/environments/dev/hiera.yaml
[root@master environments]# puppet apply --environment=dev dev/modules/testmod/tests/init.pp
Notice: Compiled catalog for master.puppetlabs.vm in environment dev in 0.10 seconds
Notice: My param in PE 3.2 is Dev is so much more better than production, friend.
Notice: /Stage[main]/Testmod/Notify[My param in PE 3.2 is Dev is so much more better than production, friend.]/message: defined 'message' as 'My param in PE 3.2 is Dev is so much more better than production, friend.'
Notice: Finished catalog run in 0.19 seconds
@gsarjeant
gsarjeant / gist:a3ad07592c81283d54fd
Created August 23, 2014 14:50
Puppet Enterprise Monolithic Master Answer File Template
#####################################################################
# ALL IN ONE INSTALL
#--------------------------------------------------------------------
# Global Answers
# These answers are always needed.
# Y or N — Whether to install. Answer files must set this to "Y".
q_install=y
@gsarjeant
gsarjeant / gist:de6d1e502ae084ef2f2e
Created August 23, 2014 14:52
Puppet Enterprise Compile-Only Master Answer File Template
#####################################################################
# COMPILE-ONLY MASTER INSTALL
#--------------------------------------------------------------------
# Global Answers
# These answers are always needed.
# Y or N — Whether to install. Answer files must set this to Y.
q_install=y
@gsarjeant
gsarjeant / gist:6e5167edfcc571d39eb9
Created August 23, 2014 14:53
Puppet Enterprise Agent Answer File Template (for use with compile-only master template)
#####################################################################
# PUPPET AGENT INSTALL
#--------------------------------------------------------------------
# Global Answers
# These answers are always needed.
# Y or N — Whether to install. Answer files must set this to "Y".
q_install=y
@gsarjeant
gsarjeant / get_environment_version.sh
Created September 22, 2014 23:20
script to retrieve most recent git commit hash
#! /bin/sh
if (( $# != 1 )); then
echo "Call this script with the name of the environment"
echo "Example: ${0} production"
exit 1
fi
ENVROOT='/etc/puppetlabs/puppet/environments'
GITDIR="${ENVROOT}/${1}/.git"
@gsarjeant
gsarjeant / gist:91b3ecb13f322ba0db25
Created October 5, 2014 21:56
Sample /etc/r10k.yaml
:cachedir: /var/cache/r10k
:sources:
infra:
basedir: /etc/puppetlabs/puppet/environments
prefix: false
remote: https://github.com/gsarjeant/puppet-master-of-masters
:purgedirs:
- /etc/puppetlabs/puppet/environments
@gsarjeant
gsarjeant / gist:3451b5589c6cc5193b1f
Created October 5, 2014 22:00
Puppet default node definition that incorporates server_role if specified
node default {
if $::server_role {
include $::server_role
}
}
@gsarjeant
gsarjeant / puppet-pre-commit
Last active August 29, 2015 14:07
Puppet module git pre-commit hook: no git-stash
#! /bin/sh
# If we don't have a HEAD, then this is the first commit and we can't do any of this
git show > /dev/null 2>&1
if [ $? -ne 0 ]; then exit 0; fi
EXITCODE=0
for file in `git diff-index --cached --diff-filter=AM --name-only HEAD`
do
echo "Validating ${file}..."
@gsarjeant
gsarjeant / rspec-puppet.basic.rb
Created October 17, 2014 21:22
Basic rspec-puppet test
require 'spec_helper'
describe('test', :type => :class) do
describe 'when called with no parameters' do
it {
should compile
should contain_file('/tmp/test').with({
@gsarjeant
gsarjeant / rspec-test-init.pp
Last active August 29, 2015 14:07
Basic puppet class for rspec demo
class test {
file { '/tmp/test':
ensure => file,
owner => root,
group => root,
}
}