Skip to content

Instantly share code, notes, and snippets.

@acidprime
acidprime / webhook_payload.rb
Last active August 29, 2015 14:12
Sync r10k then run puppet on respective environment on agents
#!/opt/puppet/bin/ruby
require 'mcollective'
require 'yaml'
include MCollective::RPC
WEBHOOK_CONFIG = '/etc/webhook.yaml'
ENV['HOME'] = '/var/lib/peadmin'
ENV['PATH'] = '/sbin:/usr/sbin:/bin:/usr/bin:/opt/puppet/bin'
@acidprime
acidprime / play-roku.lua
Last active August 29, 2015 14:11
Simple Script to pause the roku when my front door is opened.
-- Simple Lua to Pause roku when door is unlocked.
-- http://sdkdocs.roku.com/display/sdkdoc/External+Control+Guide
-- load the http module
local http = require("socket.http")
http.request{
method = "POST",
url = "http://roku.wallcity.org:8060/keydown/play",
headers =
{
["Accept"] = "*/*",
@acidprime
acidprime / environment.rb
Created December 18, 2014 18:55
puppet.conf parsing out of the box
#!/opt/puppet/bin/ruby
require 'puppet'
require 'puppet/settings/ini_file'
path = Puppet::FileSystem.pathname(Puppet.settings.which_configuration_file)
puts path
file = Puppet::Settings::IniFile.parse(path)
puts file.setting('agent','environment').value
#!/usr/bin/ruby
require 'net/imap'
imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login('[email protected]', 'wouldntyouliketoknow')
imap.select('Inbox')
# All msgs in a folder
msgs = imap.search(["SUBJECT", "Motion"])
# Read each message
@acidprime
acidprime / Entourage_Setup.scpt
Created December 3, 2014 07:15
My old Entourage Setup Script
run MainEntourageScript
script MainEntourageScript
(* Global Varibles Used in the Script*)
global TargetVersion
global theFullName
global theEmailAddr
global theAccountID
--LDAP Server Settings
global theLDAPserverName
global theLDAPServer
@acidprime
acidprime / mailconfig.sh
Created December 3, 2014 07:11
My old Mail.app configuration script
#!/bin/bash
#################################################################################
# Mail Configuration Script Tiger Ed. v10.4.X version 0.139 Updated 11/12/06 #
#################################################################################
# #
# #### #
# #### papers (a) wallcity.org #
# #### #### #
# #### #### papers.wallcity.org #
# #### #### #### #
@acidprime
acidprime / webhook.gif
Last active August 29, 2015 14:10
This is the animation gif of the r10k webhook
webhook.gif
@acidprime
acidprime / check_yaml.rb
Created November 20, 2014 21:30
Simple YAML linter for puppet
#!/opt/puppet/bin/ruby
require 'puppet'
require 'yaml'
def yaml_check(file)
YAML.load_file(file)
rescue Exception => err
puts "YAML invalid: #{file}"
puts "ERROR: #{err}"
false
@acidprime
acidprime / pre-commit
Last active August 29, 2015 14:09
Puppet Centric Pre Commit Git Hook
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'json'
def puppet_parser_validate(file)
system('puppet parser validate ' + file)
end
@acidprime
acidprime / subnet.rb
Last active August 22, 2017 19:23
Simple CIDR matching with a fact
require 'ipaddr'
# Accessible in puppet as $::subnet
Facter.add(:subnet) do
setcode do
# Mapping of vlans to ipaddresses
# NOTE: To extend this fact, modify this hash
vlan_segments = {
'prod' => IPAddr.new('10.10.10/22'),
'dev' => IPAddr.new('11.11.11/22'),
'uat' => IPAddr.new('12.12.12/22'),