Skip to content

Instantly share code, notes, and snippets.

View natemccurdy's full-sized avatar

Nate McCurdy natemccurdy

View GitHub Profile
@natemccurdy
natemccurdy / device.conf.epp
Created February 3, 2017 03:56
Build cisco device.conf with epp, iteration, and magic
#THIS FILE IS MANAGED BY PUPPET
<% $device::data.each | $switch | { -%>
[<%= $switch['certname'] %>]
type cisco
url ssh://<%= $switch['username'] %>:<%= $switch['password'] %>@<%= $switch['hostname'] %>
<% } -%>
@natemccurdy
natemccurdy / f5_loadbalancer.pp
Last active February 7, 2018 06:43
Puppet defined type to create an F5 load Balancer stack
# This defined type is used to create everything needed
# in the F5 to load-balance a set of servers.
#
# Required Parameters:
# @param nodes [Array] An array of hashes, where each hash contains a 'name', 'address', 'port', and optional 'monitors' key.
# @param pool_name [String] The name of the pool to create and manage.
# @param virtualserver_name [String] The name of the virtualserver to create and mange.
# @param destination_address [String] The IP address of the VIP destination.
#
define profile::f5::load_balancer (
@natemccurdy
natemccurdy / batman_module.txt
Last active October 12, 2017 21:44
Batman Puppet module
# A Batman module to show how to namespace classes in Puppet
batman
└── manifests
├── init.pp ==> class batman
├── belt.pp ==> class batman::belt
├── tools
│   ├── batarang.pp ==> class batman::tools::batarang
│   ├── hook.pp ==> class batman::tools::hook
│   └── smoke.pp ==> class batman::tools::smoke
@natemccurdy
natemccurdy / rbac_deploy_code.pp
Created May 20, 2016 18:41
Create a RBAC role and users that can deploy Puppet code using Code Manager
# This requires the pltraining/rbac module from the Forge. https://forge.puppet.com/pltraining/rbac
# Last tested on Puppet Enterprise 2016.1.2
#
# If an RBAC role already exists, the curl will return "There was a database conflict".
# This isn't perfect.... try at your own risk.
$deploy_role_name = 'Deploy Code'
$deploy_role_description = 'Users that are able to deploy code using Code Manager'
$console_master_certname = $::trusted['certname']
@natemccurdy
natemccurdy / dns.pp
Created May 10, 2016 16:38
Windows DNS registry entry generation
# Build a registry value string for setting DNS servers on windows
$dns_servers = [ '1.1.1.1', '2.2.2.2', '3.3.3.3' ]
$suffixes = [ '0x09', '0x0a' ]
# Generate an array that has 0x09 after the first server, and
# 0x0a after all the other servers.
$array = $dns_servers.map |$index, $server| {
if $index == 0 {
"${server},${suffixes[0]}"
@natemccurdy
natemccurdy / windows_dev_node.pp
Last active March 8, 2017 00:09
Bootstrap to make editing code on Windows better
# GETTING STARTED
# 1. Install the Puppet agent from http://downloads.puppetlabs.com/windows/puppet-agent-1.3.6-x64.msi
# 2. puppet module install chocolatey-chocolatey
# 3. puppet module install cyberious-apm
# 4. puppet apply windows_dev_node.pp
include chocolatey
$choco_packages = [
'git',
@natemccurdy
natemccurdy / application.rb
Last active May 4, 2016 17:29
application fact
# This custom fact will figure out which application
# a node belongs to by looking at the node's hostname
# and comparing that to a known list of applications.
#
# This fact relies on a naming convention where the
# first three letters of a node's hostname signify
# what application that node belongs to.
#
Facter.add(:application) do
setcode do
@natemccurdy
natemccurdy / node_classifier_backup.sh
Last active April 11, 2018 16:03
Puppet - Node Classifier Backup
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/d1abe94f9688de9d7ea38bfd3b2e8d43
# Dumps the Node Classifier groups to a file. This file can be used to restore classification.
#
SCRIPTNAME="$(basename "$0")"
PATH="/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/opt/puppet/bin:$PATH"
PE_CERT=$(puppet agent --configprint hostcert)
PE_KEY=$(puppet agent --configprint hostprivkey)
PE_CA=$(puppet agent --configprint localcacert)
@natemccurdy
natemccurdy / rc_local.pp
Created March 30, 2016 00:23
an example of Puppet's HEREDOC
$rc_local = @(RC_LOCAL)
#!/bin/sh
# This file is managed by Puppet. Any modifications will be overwritten.
touch /var/lock/sybsys/local
echo '# Increase SCSI timeout on all SCSI disks attached to the system at boot time'
ls -1 /sys/block/sd*/device/timeout | while read file
do
echo 360 > $file
@natemccurdy
natemccurdy / init.pp
Last active February 8, 2021 16:46
Windows Pagefile management with Puppet
#
# win_pagefile/manifests/init.pp
#
# Move pagefile to D: drive, reboot.
class win_pagefile (
$pagefile_drive = 'd',
) {
if $::pagefile_location =~ '[Cc]\:' or $::pagefile_automanaged == true {