Skip to content

Instantly share code, notes, and snippets.

View reidmv's full-sized avatar

Reid Vandewiele reidmv

View GitHub Profile
# <modulepath>/aix_reload/examples/test.pp
user { 'newuser007':
ensure => present,
provider => aix_reload,
before => Notify['foo'],
}
notify { 'foo': }
@reidmv
reidmv / example.pp
Created April 20, 2017 17:35
Augeas defined type example using DNS Zone
# This defined type provides a clean interface that allows users to specify DNS
# zone attributes they're familiar with - origin, ttl, etc - to manage a zone
# file. It then uses an Augeas resource to implement the configuration
# specified by the user.
#
# The Augeas type is difficult to use so it's not great to actually write a lot
# of Augeas resources. By creating ausing a defined type, we can do the
# difficult work of creating an Augeas resource once. We build ourselves a
# simple, easy-to-use repeatable resource type that we can then use multiple
# times in our Puppet code.
@reidmv
reidmv / post-receive
Last active August 29, 2015 14:22
post-receive hook for r10k bare git repo
#!/bin/bash
url='http://puppetmaster.local:8088/payload'
branches=''
while read oldrev newrev refname; do
branch=$(echo $refname | sed -n 's/^refs\/heads\///p')
branches="${branches} ${branch}"
done
@reidmv
reidmv / contained_noop.pp
Last active August 29, 2015 14:21
Contained Noop
# Requires:
# - puppetlabs/stdlib
# - trlinkin/noop
class first {
$noop_value = getparam(Class['first'], 'noop')
notice("first noop is $noop_value")
if $noop_value == true { noop() }
#!/opt/puppet/bin/ruby
require 'net/http'
require 'json'
events_query = URI.encode_www_form(
'query' => '["=","latest-report?",true]',
'summarize-by' => 'certname',
'count-by' => 'certname'
)
@reidmv
reidmv / create_environment_groups.sh
Created March 19, 2015 20:30
create_environment_groups.sh
#!/bin/bash
settings='hostcert hostprivkey localcacert'
setting_values=$(/opt/puppet/bin/puppet config print --section master $settings | tr -d ' ')
regex='(.*)=(.*)'
for setting in $setting_values; do
[[ $setting =~ $regex ]] && export puppet_${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
done
@reidmv
reidmv / 0_yum_update_in_puppet.txt
Last active August 29, 2015 14:12
Yum updates in Puppet
The following Puppet code examples demonstrate how Puppet can assist in
implementing a repository-based patching workflow. Chris St. Pierre does
a good job of describing the methodology in his whitepaper, "Staging
Package Deployment via Repository Management".
https://www.usenix.org/legacy/event/lisa11/tech/full_papers/Pierre.pdf
@reidmv
reidmv / transition_example.pp
Created November 11, 2014 21:51
Transition example
class profile::app::delicapp (
$ref = 'master',
$version = '1.2',
) {
include ::tomcat
include ::java
tomcat::instance { 'tomcat8':
catalina_base => '/opt/apache-tomcat/tomcat8',
@reidmv
reidmv / updates.pp
Created November 11, 2014 20:18
Yum Repo Updates pattern in Puppet
class updates (
$update_repo = 'patchlevel',
$enforce = false,
) {
yumrepo { 'patchlevel':
baseurl => "http://${::servername}/patches",
descr => 'Patch Level Repo',
enabled => 1,
gpgcheck => 1,
@reidmv
reidmv / transition_fragment.rb
Created November 11, 2014 00:11
autobefore in Puppet
# This type needs to implement an "autobefore" kind of behavior. Currently
# the Puppet type system only supports autorequire, so we achieve autobefore
# by hijacking autorequire.
def autorequire(rel_catalog = nil)
reqs = super
[ @parameters[:prior_to].value,
@parameters[:resource].value
].flatten.each do |rel|
reqs << Puppet::Relationship::new(self, catalog.resource(rel.to_s))