Skip to content

Instantly share code, notes, and snippets.

@rcrowley
rcrowley / cron
Created June 14, 2011 19:33
Puppet installation notes
PATH="$PATH:/var/lib/gems/1.8/bin"
*/30 * * * * root puppet agent --no-daemonize --onetime --splay
@rcrowley
rcrowley / bootstrap.sh
Created May 20, 2011 17:57
Bootstrap a Puppet agent.
set -ex
apt-get install ruby rubygems ||
yum install ruby rubygems ||
pkgin install ruby rubygems ||
false
gem install facter ${FACTER_VERSION:+"-v$FACTER_VERSION"}
gem install puppet ${PUPPET_VERSION:+"-v$PUPPET_VERSION"}
VERSION="1.9.2"
PATCH="180"
DPKG_BUILD_ARCH="$(dpkg --print-architecture)"
set -e
DESTDIR="$(mktemp -d)"
debra create "$DESTDIR"
trap "debra destroy \"$DESTDIR\"" EXIT
@rcrowley
rcrowley / deps.pp
Created November 16, 2010 00:14
Deploying Django with Puppet
stage { "pre": before => Stage["main"] }
class python {
package {
"build-essential": ensure => latest;
"python": ensure => "2.6.6-2ubuntu1";
"python-dev": ensure => "2.6.6-2ubuntu1";
"python-setuptools": ensure => "latest";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@rcrowley
rcrowley / deps.pp
Created November 9, 2010 01:46
Python dependency management with Puppet
stage { "pre": before => Stage["main"] }
class pre {
package {
"build-essential": ensure => latest;
"python": ensure => "";
"python-dev": ensure => "";
"python-setuptools": ensure => "";
}
exec { "easy_install pip":
path => "/usr/local/bin:/usr/bin:/bin",
@rcrowley
rcrowley / deps.pp
Created November 8, 2010 22:33
Ruby dependency management with Puppet
stage { "pre": before => Stage["main"] }
class pre {
package {
"build-essential": ensure => latest;
"ruby": ensure => "4.5"; # Ruby 1.8.7
"ruby-dev": ensure => "4.5"; # Ruby 1.8.7
"rubygems": ensure => "1.3.7-2";
}
}
class { "pre": stage => "pre" }
@rcrowley
rcrowley / Capfile
Created September 30, 2010 17:24
My customizations to Showoff.
set :remote, "/var/sandboxes/www/home/rcrowley/work/sfruby-2010-09-29"
role :www, "rcrowley.org"
task :static do
system "showoff static"
end
task :deploy do
static
@rcrowley
rcrowley / config.ru
Created September 29, 2010 15:16
Puppet master Rack middleware
$0 = "master"
ARGV << "--rack"
ARGV << "--certname=#{File.read("/etc/puppet/certname").chomp}"
require 'puppet/application/master'
require 'base64'
require 'json'
require 'rack/utils'
require 'yaml'
@rcrowley
rcrowley / unicorn.conf.rb
Created August 17, 2010 20:03
Unicorn logging to syslog
class Syslogger
def initialize
read, @write = IO.pipe
fork do
@write.close
$stdin.reopen read
exec *%w(logger -trails)
end
read.close
# acts_as_versioned in Rails 3
# Not too hard, but now you don't have to read the code.
class Thing < ActiveRecord::Base
acts_as_versioned :table_name => :thing_versions
def changed?(name=nil)
name && changed_attributes[name.to_s] || !changed_attributes.empty?
end
def clear_changed_attributes