Skip to content

Instantly share code, notes, and snippets.

View glarizza's full-sized avatar

Gary Larizza glarizza

  • Open Infrastructure Services
  • Portland, Oregon
View GitHub Profile
@glarizza
glarizza / gist:2142671
Created March 20, 2012 23:51
Bad Refresh
# Class: badrefresh
#
# This module manages badrefresh
#
# Parameters:
#
# Actions:
#
# Requires:
#
@glarizza
glarizza / gist:2053274
Created March 16, 2012 22:24 — forked from kwilczynski/gist:2051811
Noop Fact for Puppet
Facter.add(:noop) do
confine :kernel => :linux
result = false
setcode do
unless Facter.value(:environment).match(/^(test|dev|qa)$/)
result = true unless Time.now.utc.hour.between?(1, 10)
end
@glarizza
glarizza / gist:2012199
Created March 10, 2012 17:23
TJ Ruby Lesson part 2
┌(10007) [gary@Garys-MBP] [puppet: 2.7.12] [ ]
└(~)▷ irb
>> require 'pp'
=> true
>> bighash = { 'gary' => { 'URL' => 'http://www.google.com', 'tag' => '#puppet' }, 'tj' => { 'URL' => 'http://www.yahoo.com', 'tag' => '#ipad' } }
=> {"tj"=>{"tag"=>"#ipad", "URL"=>"http://www.yahoo.com"}, "gary"=>{"tag"=>"#puppet", "URL"=>"http://www.google.com"}}
>> pp bighash
{"tj"=>{"tag"=>"#ipad", "URL"=>"http://www.yahoo.com"},
"gary"=>{"tag"=>"#puppet", "URL"=>"http://www.google.com"}}
=> nil
@glarizza
glarizza / gist:2012187
Created March 10, 2012 17:20
TJ Ruby Lesson
┌(10006) [gary@Garys-MBP] [puppet: 2.7.12] [ ]
└(~)▷ irb
>> hash = { 'gary' => 'portland', 'tj' => 'huron' }
=> {"tj"=>"huron", "gary"=>"portland"}
>> hash['gary']
=> "portland"
>> hash['tj'] = 'lorain'
=> "lorain"
>> hash['tj']
=> "lorain"
>> puts (33..126).map{|x| ('a'..'z').include?(x.chr.downcase) ?
?> (0..9).to_a.shuffle[0].to_s + x.chr :
?> x.chr}.uniq.shuffle[0..42].join[0..42]
6N0g?2j^5q13O5H3Z6p"0K;5@9h!&>0r8:7n3D9u[}+
=> nil
@glarizza
glarizza / gist:1845952
Created February 16, 2012 15:59
Dat Error
┌(10424) [gary@Garys-MBP] [puppet: 2.7.10] [ pe-centos5.vmx ]
└(~)▷ puppet help help help help help
%%%%
%%%%-(
_%%%%%_/ \ ' /
_%%%%%%%% - (_) -
_%%%%%%%/ \% / , \
%%%%%%%%%\\ \_
%%%%%% \ \\
@glarizza
glarizza / gist:1845917
Created February 16, 2012 15:57
FPM with Prefix
Say the folder you want to package, Apache Tomcat, looks like this:
apache-tomcat-7.0.25
|-- LICENSE
|-- NOTICE
|-- RELEASE-NOTES
|-- RUNNING.txt
|-- bin
| |-- bootstrap.jar
@glarizza
glarizza / gist:1841903
Created February 16, 2012 04:11
FPM and RPMS
RPM and FPM
Install rpm-build via yum (from CentOS Updates and Base)
Install fpm via rubygems (requires json gem)
Creating an RPM from the apache-tomcat-7.0.25 directory and installing to /opt/tomcat/${Packagestuff}
fpm -s dir -t rpm -n tomcat -v 7.0.25 --prefix /opt/tomcat -C apache-tomcat-7.0.25
Creating a Puppet Module
fpm -s dir -t puppet -n tomcat -v 7.0.25 -C apache-tomcat-7.0.25
@glarizza
glarizza / gist:1790997
Created February 10, 2012 17:09
Puppet Manifest Cleanup Script
#!/usr/bin/ruby
#require 'parser-emit'
#require 'puppet::parser'
require 'puppet'
class Puppet::Parser::AST::Definition
attr_accessor :name
end
class Manifest
@glarizza
glarizza / gist:1755971
Created February 6, 2012 23:48
Packages Installed on NetSUS
## Service statuses
service { 'apache2':
ensure => 'running',
enable => 'true',
}
service { 'apparmor':
ensure => 'stopped',
enable => 'true',
}