Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
nhunzaker / gist:1995489
Created March 7, 2012 19:42
Configuring Chef Example 1
current_dir = File.dirname(__FILE__)
user = ENV['OPSCODE_USER']
log_level :info
log_location STDOUT
node_name user
client_key "#{ENV['HOME']}/.chef/#{user}.pem"
validation_client_name "#{ENV['ORGNAME']}-validator"
validation_key "#{ENV['HOME']}/.chef/#{ENV['ORGNAME']}-validator.pem"
chef_server_url "https://api.opscode.com/organizations/#{ENV['ORGNAME']}"
cache_type 'BasicFile'
@nhunzaker
nhunzaker / gist:1995525
Created March 7, 2012 19:44
Configuring Chef Example 2
export ORGNAME=your_org
export OPSCODE_USER=your_name
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_SSH_KEY_ID=name_of_your_amazon_pub_key_file
@nhunzaker
nhunzaker / gist:1995532
Created March 7, 2012 19:45
Configuring Chef Example 3
name "base"
description "Base role applied to all nodes."
run_list( "recipe[users::sysadmins]", "recipe[sudo]", "recipe[apt]", "recipe[git]" )
override_attributes( :authorization => { :sudo => { :users => ["your_name"], :passwordless => true } } )
@nhunzaker
nhunzaker / gist:1995552
Created March 7, 2012 19:48
Configuring Chef Example 4
{
"id": "rails_demo",
"server_roles": [
"rails_demo"
],
"type": {
"rails_demo": [
"rails",
"unicorn"
]
@nhunzaker
nhunzaker / gist:1995594
Created March 7, 2012 19:53
Configuring Chef Example 5
bash -c ' if [ ! -f /usr/local/bin/chef-client ]; then apt-get update sudo apt-get install -y build-essential zlib1g zlib1g-dev openssl libssl-dev cd /tmp wget ftp://ftp.ruby-lang.org//pub/ruby/1.9/ruby-1.9.2-p290.tar.gz tar xvf ruby-1.9.2-p290.tar.gz cd ruby-1.9.2-p290 ./configure make
sudo make install
sudo gem update --system
gem update
gem install ohai --no-rdoc --no-ri --verbose
gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>;
fi mkdir -p /etc/chef ( cat &lt;&lt;'EOP' <%= validation_key %> EOP ) %> /tmp/validation.pem
awk NF /tmp/validation.pem > /etc/chef/validation.pem
rm /tmp/validation.pem ( cat <<'EOP' <%= config_content %> EOP ) > /etc/chef/client.rb ( cat <<'EOP' <%= { "run_list" => @run_list }.to_json %> EOP ) > /etc/chef/first-boot.json /usr/local/bin/chef-client -j /etc/chef/first-boot.json'
@nhunzaker
nhunzaker / gist:1995626
Created March 7, 2012 19:55
Configuring Chef Example 5
Instance ID: i-48b83b28
Flavor: m1.small
Image: ami-7000f019
Region: us-east-1
Availability Zone: us-east-1a
Security Groups: single_instance_production
SSH Key: ampms
Root Device Type: instance-store
Public DNS Name: ec2-50-19-193-102.compute-1.amazonaws.com
Public IP Address: 50.19.193.102
@nhunzaker
nhunzaker / gist:2001888
Created March 8, 2012 16:22
Configuring Chef Example 6
{
"groups": "sysadmin",
"ssh_keys": "ssh-rsa AAAAB3Nz...",
"id": "your_name",
"shell": "/bin/bash"
}
@nhunzaker
nhunzaker / gist:2001901
Created March 8, 2012 16:23
Configuring Chef Example 7
knife cookbook site vendor application
knife cookbook site vendor apt
knife cookbook site vendor git
knife cookbook site vendor haproxy
knife cookbook site vendor mongodb
knife cookbook site vendor users
@nhunzaker
nhunzaker / spree_variant_options.rb
Created March 12, 2012 15:11
Precompiling Assets for Spree Variant Options Plugin
require 'spree_core'
require 'spree_sample' unless Rails.env == 'production'
# All of the magic happens at the line "if Rails.version >= 3.1 ... "
# found in spree_variant_options/lib/spree_variant_options.rb
module SpreeVariantOptions
class Engine < Rails::Engine
@nhunzaker
nhunzaker / microtest.js
Created March 23, 2012 20:03
A super simple self-tested testing framework for javascript
// Implementation
// -------------------------------------------------- //
function assert(condition, opt_message) {
'use strict';
if (!condition) {
var msg = 'Assertion failed';
if (opt_message) {
msg = msg + ': ' + opt_message;