Skip to content

Instantly share code, notes, and snippets.

View natemccurdy's full-sized avatar

Nate McCurdy natemccurdy

View GitHub Profile
@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 / 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 / pe_repo_packages.pp
Last active January 5, 2018 05:21
Puppet class to synchronize pe_repo packages to off-line compile masters
# This class is meant to solve the problem of synchronizing pe_repo agent
# packages to compile masters when there is no internet access.
#
# This profile assumes that the Puppet MoM (master of masters) is able to reach
# the internet to download the needed packages, or they've been sneaker-netted to the MoM.
#
class pe_repo_packages {
# Generate an array of puppet-agent pe_repo package names.
# 1. Searches PuppetDB for all pe_repo::platform classess added to the MoM.
@natemccurdy
natemccurdy / filter.pp
Last active April 18, 2017 22:17
Find the name of a key whose attribute matches some string
$service_accounts = {
'larry' => {
gid => '1111',
tag => 'group_a',
},
'moe' => {
gid => '2222',
tag => 'group_b',
},
'curly' => {
@natemccurdy
natemccurdy / config_version.rb
Last active April 26, 2017 21:58
Puppet config version script
#!/opt/puppetlabs/puppet/bin/ruby
require 'json'
require 'socket'
compile_master = Socket.gethostname
environmentpath = ARGV[0]
environment = ARGV[1]
# Get the short SHA1 commit ID from the control repository.
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
@natemccurdy
natemccurdy / pihole-docker-compose.yaml
Created April 28, 2017 20:58
PiHole Puppet profile w/ docker-compose
pihole:
image: diginc/pi-hole
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80/tcp"
cap_add:
- NET_ADMIN
environment:
ServerIP: 10.72.0.5
@natemccurdy
natemccurdy / disable_uac.pp
Created May 4, 2017 19:33
windows profiles
# This will disable UAC on Windows nodes.
#
# Requires: puppetlabs/registry
#
class profile::windows::disable_uac {
registry::value { 'Disable UAC':
key => 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System',
value => 'EnableLUA',
data => '0',
type => 'dword',
# Custom fact that shows the current name of the Administrator and
# Guest accounts based on well-known SID's.
#
# http://support.microsoft.com/kb/243330
#
require 'puppet'
Facter.add(:account_names) do
confine osfamily: :windows
@natemccurdy
natemccurdy / Install-CCM-Agent.ps1.epp
Last active February 17, 2022 04:41
Puppet code to install SCCM Agent on Windows
<%- | String $client_source,
String $argument_list
| -%>
$ClientSource = "<%= $client_source %>"
$TempDir = Join-Path "C:\Windows\Temp" "ccm_client"
$CCMSetup = Join-Path $TempDir "ccmsetup.exe"
if (-not (Test-Path $CCMSetup)) {
Try {
Write-Output "Copying $ClientSource to $TempDir"
@natemccurdy
natemccurdy / autosign.rb
Created October 6, 2017 21:33
Puppet policy-based autosign script: pre-shared key
#!/opt/puppetlabs/puppet/bin/ruby
#
# A note on logging:
# This script's stderr and stdout are only shown at the DEBUG level
# of the master's logs. This means you won't see the error messages
# in puppetserver.log by default. All you'll see is the exit code.
#
# https://docs.puppet.com/puppet/latest/ssl_autosign.html#policy-executable-api
#
# Exit Codes: