Skip to content

Instantly share code, notes, and snippets.

View schisamo's full-sized avatar

Seth Chisamore schisamo

View GitHub Profile
~$ date
Thu Nov 12 23:46:51 UTC 2009
~$ sudo cp /usr/share/zoneinfo/EST /etc/localtime
~$ sudo ntpdate ntp.ubuntu.com
12 Nov 18:47:15 ntpdate[5012]: adjust time server 91.189.94.4 offset -0.002164 sec
~$ date
Thu Nov 12 18:47:17 EST 2009
mxmapp@chef:~$ ps aux | grep chef
root 935 0.0 4.5 37408 23020 ? Sl 07:56 0:04 /usr/bin/ruby1.8 /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20
root 2494 60.3 3.1 21348 16120 ? R 09:18 13:23 ruby /usr/bin/chef-indexer -d -c /etc/chef/indexer.rb
mxmapp 2744 0.0 0.1 3036 788 pts/0 R+ 09:40 0:00 grep --color=auto chef
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
# open up mongodb port on iptables
require_recipe "iptables"
iptables_rule "port_mongodb" do
variables(:port => config[:port])
end
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
# pull existing files down
rm -rf /tmp/cms
scp -i ~/.ssh/id_rsa_storage -rp storage@some_server_ip:/var/backups/mongodb/cms/ /tmp
# drop the mongo db
/usr/local/mongodb/bin/mongo --eval "db.dropDatabase()" cms
# restore your mongo db and collections
/usr/local/mongodb/bin/mongorestore -d cms --dir /tmp/cms
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'chef'
hosts = "# Host File generated from Chef Search on #{Time.now}\n"
# perform search via knife and loop through results
JSON.parse(%x(knife list_nodes)).each do |n|
# parse result as Chef::Node..uses the result json_type
node = JSON.parse(%x(knife show_node --node=#{n}))
# Hot deploy Rails apps (rolling restart) with Capistrano, Haproxy, and cluster of Passengers
# Capistrano config
namespace :passenger do
task :disable_load_balancing, :roles => :app do
run "rm -f #{current_path}/public/http-check.txt"
end
task :enable_load_balancing, :roles => :app do
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
#
# Cookbook Name:: haproxy
# Recipe:: default
#
# Copyright 2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#