Skip to content

Instantly share code, notes, and snippets.

View natemccurdy's full-sized avatar

Nate McCurdy natemccurdy

View GitHub Profile
@natemccurdy
natemccurdy / masters
Last active December 20, 2017 20:47
Script to return list of masters. Useful in Bolt, for loops, and scripting
#!/usr/bin/env ruby
require 'yaml'
require 'optparse'
options = {
file: File.expand_path('masters.yaml'),
type: nil,
environment: nil
}
@natemccurdy
natemccurdy / datacenter.rb
Last active May 26, 2018 21:53
Datacenter Fact
# A fact that uses CIDR network ranges to determine a node's datacenter.
#
# gist url: https://gist.github.com/natemccurdy/b434e0b24401f5bb1decf394fbe1d503
#
require 'ipaddr'
Facter.add(:datacenter) do
setcode do
# This hash defines the map of network segments to datacenters.
# NOTE: To extend this fact, modify this hash with your segments and datacenters.
datacenter_map = {
@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:
@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"
# 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 / 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',
@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 / 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 / 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 / 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.