Skip to content

Instantly share code, notes, and snippets.

search(:node, "role:#{app_info['prod_role']}").each do |server|
Chef::Log.info("Found a server: #{server} IP: #{server.cloud.private_ips.first}")
server_list << server.cloud.private_ips.first
end
server_list.sort!
bash -c '
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
yum install -y ruby ruby-devel gcc gcc-c++ automake autoconf make
wget -O /tmp/rubygems-1.3.7.tgz http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xzf /tmp/rubygems-1.3.7.tgz -C /tmp
ruby /tmp/rubygems-1.3.7/setup.rb
rm -rf /tmp/rubygems-1.3.7
# /opt/rightscale/sandbox/bin/chef-solo -c /tmp/chef.rb -j /tmp/solo.json
[Fri, 21 Jan 2011 18:32:23 +0000] INFO: Starting Chef Solo Run
[Fri, 21 Jan 2011 18:32:24 +0000] INFO: Replacing the run_list with ["recipe[load_balancer::elb_register]"] from JSON
[Fri, 21 Jan 2011 18:32:24 +0000] WARN: Missing gem 'right_aws'
[Fri, 21 Jan 2011 18:32:25 +0000] INFO: Installing gem_package[fog] version 0.4.0
[Fri, 21 Jan 2011 18:32:44 +0000] WARN: Mising the 'fog' gem
[Fri, 21 Jan 2011 18:32:44 +0000] ERROR: load_balancer_elb[test-lb] (/opt/rightscale/sandbox/lib/ruby/gems/1.8/gems/chef-0.8.16.3/lib/chef/mixin/recipe_definition_dsl_core.rb line 59) had an error:
uninitialized constant Chef::Provider::LoadBalancerElb::Fog
/root/rightscale_cookbooks/load_balancer/providers/elb.rb:13:in `elb'
/root/rightscale_cookbooks/load_balancer/providers/elb.rb:18:in `class_from_file'
# COLORS
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[1;36m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]";
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]";
# GIT PROMPT (http://gist.github.com/120804)
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';
}
function parse_git_status {
git status 2> /dev/null | sed -e '/(working directory clean)$/!d' | wc -l;
}
@crazed
crazed / gist:1289961
Created October 15, 2011 18:41
simple chef fist-boot generator
require 'rubygems'
require 'sinatra'
require 'json'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('nodes')
config.max_retries_on_connection_failure = 1
end
@crazed
crazed / ip.rb
Created December 2, 2011 21:42
useful facter plugins
if File::exists?("/sbin/ip")
Facter.add('gateway') do
setcode do
`/sbin/ip route show`.match(/^default.*/)[0].match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)[0]
end
end
end
@crazed
crazed / pre-commit.sh
Created May 25, 2012 16:59
pre-commit hook for puppet syntax validation
#!/usr/bin/env bash
TEMPDIR=`mktemp -d puppet-parser.XXXXXX`
test -n "$TEMPDIR" || exit 1
test -d "$TEMPDIR" || exit 1
git checkout-index --prefix="$TEMPDIR/" -af
changed_manifests=$(git diff --cached --name-only --diff-filter=ACM | grep '.pp$' | xargs -n 1 -I '{}' echo $TEMPDIR/'{}' | tr '\n' ' ')
require 'net/https'
uri = URI.parse("https://blah.com/test")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
request = Net::HTTP::Get.new(uri.path)
results = http.request(request)
commit d9b01934d56a96d9f4ae2d6204d4ea78a36f5f36
Author: Ted Ts'o <tytso@mit.edu>
Date: Sat Apr 30 13:17:11 2011 -0400
jbd: fix fsync() tid wraparound bug
If an application program does not make any changes to the indirect
blocks or extent tree, i_datasync_tid will not get updated. If there
are enough commits (i.e., 2**31) such that tid_geq()'s calculations
wrap, and there isn't a currently active transaction at the time of
#!/usr/bin/env ruby
require 'rubygems'
require 'mcollective'
class MCollectiveCheck
NAGIOS_CRITICAL = 2
NAGIOS_WARNING = 1
NAGIOS_OK = 0
include MCollective::RPC