Skip to content

Instantly share code, notes, and snippets.

View natemccurdy's full-sized avatar

Nate McCurdy natemccurdy

View GitHub Profile
@natemccurdy
natemccurdy / blog.pp
Last active February 3, 2017 00:05
Puppet Fundamentals Capstone
# $modulepath/profiles/manifests/blog.pp
class profiles::blog {
include mysql::server
include mysql::bindings
include apache
include apache::mod::php
include wordpress
}
@natemccurdy
natemccurdy / has_wordpress.pp
Last active August 29, 2015 14:14
Check if Wordpress is installed for Fundamentals Capstone Lab
#/etc/puppetlabs/puppet/modules/classroom/lib/facter/has_wordpress.rb
require 'net/http'
Facter.add('has_wordpress') do
setcode do
begin
http = Net::HTTP.new(Facter.value("ipaddress"), '80')
req = Net::HTTP::Get.new('/wp-login.php')
req['Content-Type'] = 'plain/html'
resp = http.request(req)
@natemccurdy
natemccurdy / index.html
Last active June 2, 2016 23:26
index.html for nginx lab
<html>
<head>
<style>
.blink {
animation: blink 1s steps(5, start) infinite;
-webkit-animation: blink 1s steps(5, start) infinite;
}
@keyframes blink {
to {
visibility: hidden;
@natemccurdy
natemccurdy / inventory.mc
Created July 16, 2015 20:15
Practitioner: inventory report
inventory do
format "%25s: %15s [ %s / %s ]"
fields { [
identity,
facts["ipaddress"],
facts["memoryfree"],
facts["memorysize"]
] }
end
@natemccurdy
natemccurdy / disable_firewall.pp
Created October 22, 2015 17:17
Puppet profiles for managing basic Windows settings
# This will disable the windows firewall
#
# Requires: puppetlabs/registry
#
class profile::windows::disable_firewall {
registry::value { 'Disable DomainProfile firewall':
key => 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\DomainProfile',
value => 'EnableFirewall',
data => '0',
@natemccurdy
natemccurdy / known_hosts.pp
Created November 18, 2015 01:50
Automagically create known_hosts entries with Puppet
# This example shows how to automatically populate the SSH known_hosts file
# on a node so that SSH'ing to the node won't ask you to verify it's fingerprint.
# This requires a version of Facter that uses structure facts.
# Node 'foo' exports its public HOST KEY.
node 'foo' {
@@sshkey { $::clientcert:
ensure => present,
host_aliases => [$::ipaddress],
@natemccurdy
natemccurdy / manual_code_deploy.sh
Last active April 19, 2024 13:21
Manually trigger code-manager and file-sync
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/797fa9128b7eef1f07be
# This script can be run to manually trigger Code Manager to deploy code from your control-repo. This sort of
# thing is neccesary when, for example:
# - You've turned on Code Manager but have not yet made an RBAC token.
# - You want to pull down the latest version of a Puppetfile module without pushing to your GMS.
# - Something has broken the post-receive hook on your GMS that would've triggered Code Manager.
# - Syntax errors in your Puppetfile prevent you from retrieving those fixes to that Puppetfile.
# - Puppetserver has crashed due to file-sync issues between code and code-staging.
# - Code Manager can't deploy your code for various reasons that are hard to track down.
@natemccurdy
natemccurdy / search-for-class.sh
Last active March 15, 2016 20:32
Search for list of classes in puppetserver API
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/df8a2ca00f3783e7931e
# This script searches the puppetserver API for all known classes that match ^pe_.*
# Adjust the search pattern to tailor this script to your particular search pattern.
# Set variables for the curl.
CERT="/etc/puppetlabs/puppet/ssl/certs/pe-internal-classifier.pem"
KEY="/etc/puppetlabs/puppet/ssl/private_keys/pe-internal-classifier.pem"
CACERT="/etc/puppetlabs/puppet/ssl/certs/ca.pem"
@natemccurdy
natemccurdy / last-class-update.sh
Last active March 15, 2016 20:23
Check when the last class refresh happened in the Puppet Node Classifier
#!/bin/bash
# GIST_URL: https://gist.github.com/b68497e1769c16e8fab0
# Get the timestamp of the last class update in the Node Classifier.
# This can be run from any Puppet Master or the Puppet Console.
# https://docs.puppetlabs.com/pe/latest/nc_last_class_update.html
CONFDIR="$(puppet master --configprint confdir)"
CERT="$(puppet master --confdir "${CONFDIR}" --configprint hostcert)"
CACERT="$(puppet master --confdir "${CONFDIR}" --configprint localcacert)"
@natemccurdy
natemccurdy / update-classes.sh
Last active March 18, 2016 23:46
Update the list of classes in the Puppet NC
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/fb01fac7eba615fa8056
# Trigger the update-classes endpoint of the Puppet Node Classifier.
# This will update the list of classes available to the NC.
#https://docs.puppetlabs.com/pe/latest/nc_update_classes.html#post-v1update-classes
CONFDIR="$(puppet master --configprint confdir)"
CERT="$(puppet master --confdir "${CONFDIR}" --configprint hostcert)"
CACERT="$(puppet master --confdir "${CONFDIR}" --configprint localcacert)"