Skip to content

Instantly share code, notes, and snippets.

View jeffmccune's full-sized avatar

Jeff McCune jeffmccune

View GitHub Profile
@jeffmccune
jeffmccune / fsck_me.rb
Created December 7, 2011 04:51
Urge to kill rising...
class String
ZAML_ESCAPES = %w{\x00 \x01 \x02 \x03 \x04 \x05 \x06 \a \x08 \t \n \v \f \r \x0e \x0f \x10 \x11 \x12 \x13 \x14 \x15 \x16 \x17 \x18 \x19 \x1a \e \x1c \x1d \x1e \x1f }
def escaped_for_zaml
gsub( /\x5C/u, "\\\\\\" ). # Demi-kludge for Maglev/rubinius; the regexp should be /\\/ but parsetree chokes on that.
gsub( /"/u, "\\\"" ).
gsub( /([\x00-\x1F])/u ) { |x| ZAML_ESCAPES[ x.unpack("C")[0] ] }.
gsub( /([\x80-\xFF])/n ) { |x| "\\x#{x.unpack("C")[0].to_s(16)}" }
end
end
@jeffmccune
jeffmccune / type_provider_doc_irb.irb
Created December 14, 2011 01:06
Puppet Documentation for all types and providers found
[jeff@maynard] (2.7.x)(clean) 1.8.7@puppet src/puppet/lib/puppet
% irb
1.8.7 :001 > require 'puppet'
=> true
1.8.7 :002 > Puppet::Type.loadall
=> ["/vagrant/src/puppet/lib/puppet/type/augeas.rb", "/vagrant/src/puppet/lib/puppet/type/component.rb", "/vagrant/src/puppet/lib/puppet/type/computer.rb", "/vagrant/src/puppet/lib/puppet/type/cron.rb", "/vagrant/src/puppet/lib/puppet/type/exec.rb", "/vagrant/src/puppet/lib/puppet/type/file.rb", "/vagrant/src/puppet/lib/puppet/type/filebucket.rb", "/vagrant/src/puppet/lib/puppet/type/group.rb", "/vagrant/src/puppet/lib/puppet/type/host.rb", "/vagrant/src/puppet/lib/puppet/type/interface.rb", "/vagrant/src/puppet/lib/puppet/type/k5login.rb", "/vagrant/src/puppet/lib/puppet/type/macauthorization.rb", "/vagrant/src/puppet/lib/puppet/type/mailalias.rb", "/vagrant/src/puppet/lib/puppet/type/maillist.rb", "/vagrant/src/puppet/lib/puppet/type/mcx.rb", "/vagrant/src/puppet/lib/puppet/type/mount.rb", "/vagrant/src/puppet/lib/puppet/type/nagios_command.rb", "/vagrant/src/pup
@jeffmccune
jeffmccune / init.pp
Created January 6, 2012 21:44
Style Guide 11.9
# = motd class
#
# A Hierarchy of Class Param Value => Node Param Value => Module Default Value
#
# WITHOUT _real and UNSET ugliness! Hooray!
# ... but WITH inherits! Boo..?
#
# The class param value part of the hierarchy happens here since this is a parameterized class.
# The node param value and module default part of the hierarchy happens in params class
# we're inheriting from.

Stdlib

  • 2.1.x (PE 2.0.x)

  • 2.2.x

  • master

  • 2.1.x → master 184 Commits

  • 2.1.x → 2.2.x 177 Commits

  • 2.2.x → master 6 Commits

@jeffmccune
jeffmccune / jenkins_motw.md
Created April 10, 2012 06:07
Jenkins MOTW Blog Post

Jenkins MOTW Blog Post

root@pe-centos6:~# puppet module install rtyler/jenkins
Preparing to install into /etc/puppetlabs/puppet/modules ...
Downloading from http://forge.puppetlabs.com ...
Installing -- do not interrupt ...
/etc/puppetlabs/puppet/modules
└─┬ rtyler-jenkins (v0.2.1)

└── puppetlabs-apt (v0.0.2)

@jeffmccune
jeffmccune / root_user.pp
Created April 11, 2012 18:01
Manage the Root User Password on Linux
# = Class: site::root_user
#
# This is a simple class to manage the root user password.
# The shadow hash of an existing password can be easily obtained
# by running `puppet resource user root` on a Linux system
# that has the desired root password already set.
# Puppet will then manage this password everywhere.
#
# First, I set the password to "puppet" on one Linux node and then get back the
# shadow hash.
@jeffmccune
jeffmccune / puppet_mysql.md
Created April 11, 2012 23:42
Puppet Database

Install the MySQL module in PE 2.5

This module is located at http://forge.puppetlabs.com/puppetlabs/mysql

Installing the module is a single command in PE 2.5

root@pe-centos6:~# puppet module install puppetlabs-mysql

Preparing to install into /etc/puppetlabs/puppet/modules ...

@jeffmccune
jeffmccune / lucid_sources.list
Created April 16, 2012 05:42
Lucid Sources
#############################################################
################### OFFICIAL UBUNTU REPOS ###################
#############################################################
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
@jeffmccune
jeffmccune / different_versions.rb
Created April 16, 2012 16:41
Sorting out Exceptions at Runtime
#! /usr/bin/env ruby
module Stomp
class Error < StandardError
end
end
module Jeff
def self.unknown_error
if Stomp.const_defined? "Error"
@jeffmccune
jeffmccune / subkey.pp
Created April 17, 2012 23:02
Registry Defined Type
# Use it
# I want this windows machine to announce the time as described at:
# http://support.microsoft.com/kb/816042
registry::subkey { 'HKLM\System\CurrentControlSet\Services\W32Time\Config\AnnounceFlags':
value_data => 'A',
value_type => DWORD,
}
# The definition