Skip to content

Instantly share code, notes, and snippets.

View jbz's full-sized avatar

J.B. Zimmerman jbz

View GitHub Profile
license_file_contents = NIL
if Chef::DataBag.list.key?('pmta_licenses')
Chef::Log.warn("Found pmta_licenses data bag...")
begin
license_file_contents = data_bag_item("pmta_licenses", node['hostname'])['license']
Chef::Log.warn("found hostname license in data bag...")
file "/etc/pmta/license" do
owner 'pmta'
group 'pmta'
mode 0640
%w{ package1 package2 package3 }.each do |pkg|
package pkg do
action :install
end
end
@jbz
jbz / bootstrap_os_x.sh
Created April 13, 2010 19:01 — forked from petitbon/bootstrap_os_x.sh
Ruby tech stack install script for OS X
cp ~/.profile ~/.profile.bak
echo 'export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"' > ~/.profile
. ~/.profile
echo 'Creating src directory'
mkdir ~/src
cd ~/src
echo 'Installing MySQL'
#! /bin/sh
### BEGIN INIT INFO
# Provides: cruisecontrol.rb
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: CruiseControl.rb
# Description: Continuous build integration system. This runs the web interface (via mongrel and the builders).
### END INIT INFO
@jbz
jbz / gist:628717
Created October 15, 2010 18:47 — forked from ktheory/gist:628713
gem package hashing
# In attribute file:
my_gem_packages = [
"nokigiri", # Only a gem name, without a version requirement or other options"
["bundler", "=1.0.0"], # A gem with a version requirement
["rails", "~>2.3.9", "--no-ri --no-rdoc --source http://rubygems.org"], # A gem with a version requirement and options"
["json", nil, "--source http://rubygems.org"] # Gem with options but no version requirement
]
# In recipe:
#!/usr/bin/env ruby
require "rubygems"
require "erb"
require "fileutils"
require "json"
require "net/ssh"
require "net/scp"
require "optparse"
# from rsyslog::default.rb:
service "rsyslog" do
supports :restart => true, :reload => true
action [:enable, :start]
end
# from rsyslog/providers/imfile.rb:
jzimmerman@ip-10-117-53-160:/etc/rsyslog.d$ sudo chef-client
[Wed, 26 Jan 2011 23:03:30 +0000] INFO: Starting Chef Run (Version 0.9.12)
[Wed, 26 Jan 2011 23:03:32 +0000] INFO: Writing updated content for template[/etc/rsyslog.d/nginx-main-error.conf] to /etc/rsyslog.d/nginx-main-error.conf
[Wed, 26 Jan 2011 23:03:32 +0000] INFO: template[/etc/rsyslog.d/nginx-main-error.conf] sending reload action to service[rsyslog] (delayed)
[Wed, 26 Jan 2011 23:03:32 +0000] ERROR: Running exception handlers
[Wed, 26 Jan 2011 23:03:32 +0000] ERROR: Exception handlers complete
/usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:53:in `run_action': undefined method `run_action' for "service[rsyslog]":String (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:101:in `converge'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:97:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/runner.rb:97:in `converge'
########################################################################
### NOTICE: this file managed by chef; changes made here will be lost.
########################################################################
# ubuntu defaults, left here for compatibility
root ALL=(ALL) ALL
%admin ALL=(ALL) NOPASSWD:ALL
# Amazon EC2 ubuntu user - DO NOT REMOVE FROM EC2 NODES
# ubuntu user is default user in ec2-images.
@jbz
jbz / knife.rb
Created February 16, 2011 17:08
knife.rb that switches Opscode orgs/validators based on git branch
# This knife.rb orig. provided by jtimberman@opscode.com - but any mistakes are mine!
current_dir = File.dirname(__FILE__)
platform = "https://api.opscode.com/organizations"
require 'grit'
branch = Grit::Repo.new("#{current_dir}/..").head.name
case branch