Skip to content

Instantly share code, notes, and snippets.

View reidmv's full-sized avatar

Reid Vandewiele reidmv

View GitHub Profile
@reidmv
reidmv / tarball-to-commit.sh
Created March 16, 2022 23:26
Example script that uses a Git repo as a vehicle for storing content from a tarball as a new commit
#!/bin/bash
# This script demonstrates using a Git repo as a vehicle for storing content
# from a tarball. It creates new commits, children of a given repo's current
# HEAD, which contain exactly the contents of a given tarball. No consideration
# is given to the prior commit's contents when constructing the new commit.
# Basic usage message if incorrect number of params passed
if [ $# -ne 2 ]; then
echo "Usage: ${0} <path-to-tarball.tar.gz> <git@clone.url>"
@reidmv
reidmv / get-matching-nodes.rb
Created November 25, 2020 23:17
Return list of nodes matching a named PE console node group
#!/opt/puppetlabs/puppet/bin/ruby
require 'json'
require 'net/http'
require 'etc'
def http(uri:, body: {}, request_class: Net::HTTP::Get)
token_file = File.join(Etc.getpwuid.dir, '.puppetlabs', 'token')
token = File.read(token_file)
#!/opt/puppetlabs/puppet/bin/ruby
# This script exists to convert the output of simple PuppetDB queries into
# CSV format (tab-separated). It expects a JSON array of objects with
# string/string keys/values.
require 'json'
require 'csv'
# Read in the PuppetDB query data from STDIN or filename argument
@reidmv
reidmv / cd4pe-workflow.md
Last active April 9, 2022 16:36
cd4pe-workflow.md

CD4PE Workflow

Puppet is a tool to enable organizations to deliver change. This document describes the workflow and process for doing that. Breaking it down, there are three parts to this document.

  1. Overview all the different kinds of infrastructure-as-code content users and developers can interact with.
  2. Describe the development process for proposing changes to any of the Puppet content described above.
  3. Describe the deployment process for accepting, promoting, and eventually deploying in production changes to any of the Puppet content described above.

Puppet Content

@reidmv
reidmv / compiler_factmerge.rb
Last active March 13, 2019 17:06
Catalog terminus to inject node data
# Example catalog terminus
require 'puppet/indirector/catalog/compiler'
class Puppet::Resource::Catalog::CompilerFactmerge < Puppet::Resource::Catalog::Compiler
def find(request)
if request.options[:use_node]
request.options[:use_node].add_extra_facts(node_data)
else
# This function returns a boolean value based on whether or not the Puppet agent
# was invoked with --no-noop.
#
# `puppet agent -t` = true
# `puppet agent -t --no-noop` = false
#
function noop::true_unless_no_noop() {
$agent_specified_noop_setbycli ? {
true => $facts['agent_specified_noop'],
false => true,
@reidmv
reidmv / haproxy.pp
Last active April 4, 2018 22:09
HAProxy configuration for forwarding to Puppet webhook
class { 'haproxy':
global_options => {
'log' => "${::ipaddress} local2",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => 5000,
'user' => 'haproxy',
'group' => 'haproxy',
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats',
@reidmv
reidmv / pe-pg_repack.md
Last active May 21, 2019 16:31
pe-pg_repack.md

Instructions for getting started with pg_repack in Puppet Enterprise:

NOTE: there are some PE version numbers in some of the code blocks. You'll need to update these to the correct numbers for your deployment.

To create an RPM package for pg_repack (using FPM):

First install the dependencies (requires root):

yum install pe-postgresql-devel zlib-devel readline-devel gcc -y
---
pkcs7_private_key: "/etc/puppetlabs/puppet/keys/private_key.pkcs7.pem"
testclass::secret: ENC[PKCS7,MIIBeQYJKoZIhvcNAQcDoIIBajCCAWYCAQAxggEhMIIBHQIBADAFMAACAQEwDQYJKoZIhvcNAQEBBQAEggEAXQSL1llpvXtwuCPquIBNgOvaEu4rYPY1XYLEqSi4iCTTaCaXj5GCcEmcyw68liLPRnCwp+E+OhWLOvhxEQM9BPrR+miU1Zol+bhkL3vIE84f8JVCvqOESBNfKiVoABd73CjaDVQfDXVJR8XR57JCRTTzNc+fk88pwcczTNFzUCRtnWYZxMtWudse4Z9jFkioDhsKYoQqugsqhobBpIzGnQOaoEJeUYALyqusVa7mZrNlT0xNBccNk2aAxGEdLay3LdCqOBpsnk/vMwzv1pw8OuT17UWKTSBhRxwg2w+Mk9TZHFKsZ9wmY0cMU+i83tC6jDlA7Clti9ypH0/y72tDhzA8BgkqhkiG9w0BBwEwHQYJYIZIAWUDBAEqBBCymI8i2C1wRAJymKgNjbWxgBA854B413xC5Udmhhx4P4BG]