Skip to content

Instantly share code, notes, and snippets.

@Drewzar
Drewzar / gist:939672
Created April 24, 2011 16:30
knife ec2
knife ec2 server create "role[webserver]" -i ami-399ca94d -f m1.small -S knife -I ~/.ssh/knife.pem --ssh-user ubuntu
@Drewzar
Drewzar / gist:1100441
Created July 22, 2011 21:12
monit wrapper
#!/bin/bash
case $1 in
start)
echo $$ > /var/run/znc.pid;
exec znc -d /var/lib/znc/.znc ;;
stop)
kill 'cat /var/run/znc.pid' ;;
*)
echo "usage: goznc {start|stop}" ;;
@Drewzar
Drewzar / gist:1181426
Created August 30, 2011 17:27
stacktrace
13:14:21-deploy@ec2-50-19-161-84:/etc/chef$ cat /var/chef/cache/chef-stacktrace.out
Generated at 2011-08-30 13:14:21 -0400
NoMethodError: ruby_block[cloudkick data load] (cloudkick::default line 65) had an error: undefined method `map' for false:FalseClass
/usr/local/lib/ruby/gems/1.9.1/gems/cloudkick-0.2.16/lib/cloudkick/node.rb:65:in `get'
/usr/local/lib/ruby/gems/1.9.1/gems/cloudkick-0.2.16/lib/cloudkick/node.rb:49:in `initialize'
/usr/local/lib/ruby/gems/1.9.1/gems/cloudkick-0.2.16/lib/cloudkick/base.rb:45:in `new'
/usr/local/lib/ruby/gems/1.9.1/gems/cloudkick-0.2.16/lib/cloudkick/base.rb:45:in `get'
/var/chef/cache/cookbooks/cloudkick/libraries/cloudkick_data.rb:25:in `get'
/var/chef/cache/cookbooks/cloudkick/recipes/default.rb:69:in `block (2 levels) in from_file'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/provider/ruby_block.rb:28:in `call'
@Drewzar
Drewzar / gist:1181442
Created August 30, 2011 17:32
full run
13:13:45-deploy@ec2-50-19-161-84:/etc/chef$ sudo chef-client -j cloudkick.json
[Tue, 30 Aug 2011 13:14:16 -0400] INFO: *** Chef 0.10.4 ***
[Tue, 30 Aug 2011 13:14:17 -0400] INFO: Setting the run_list to ["role[cloudkick]"] from JSON
[Tue, 30 Aug 2011 13:14:17 -0400] INFO: Run List is [role[cloudkick]]
[Tue, 30 Aug 2011 13:14:17 -0400] INFO: Run List expands to [cloudkick]
[Tue, 30 Aug 2011 13:14:17 -0400] INFO: Starting Chef Run for -base64-ubuntu-ebs-1
[Tue, 30 Aug 2011 13:14:18 -0400] INFO: Loading cookbooks [apt, cloudkick]
[Tue, 30 Aug 2011 13:14:18 -0400] INFO: Storing updated cookbooks/cloudkick/libraries/cloudkick_data.rb in the cache.
[Tue, 30 Aug 2011 13:14:19 -0400] INFO: Processing apt_repository[cloudkick] action add (cloudkick::default line 22)
[Tue, 30 Aug 2011 13:14:19 -0400] INFO: Processing remote_directory[/usr/lib/cloudkick-agent/plugins] action create (cloudkick::default line 31)
#!/usr/bin/env ruby
queue_length = `/opt/redis-2.2.2/bin/redis-cli zcard q:jobs:total_report:inactive`
begin
if queue_length.to_i > 50000
puts "status ok there are #{queue_length.to_i} jobs"
elsif queue_length > 10000
puts "status warn there are #{queue_length.to_i} jobs"
else
puts "status err there are #{queue_length.to_i} jobs"
template "/etc/monit/conf.d/#{app['id']}.monitrc" do
if app['id'] = fdog
source "fdog.monitrc.erb"
else
source "site.monitrc.erb"
end
notifies :run, "execute[monit]"
variables(
:local_ip => node.ec2.local_ipv4,
:app_name => app['id'],
description "@app_name"
author "Vitrue, Inc"
start on startup
stop on shutdown
script
export HOME="/root"
<%- @env_vars.each do |k, v| -%>
export <%= k %>=<%= v %>
move_bins = []
node[:redis][:bins].each { |bin|
unless (File.exists?("#{node[:redis][:dir]}/bin/#{bin}") && File.exists?("/#{BASE}/src/redis-#{node[:redis][:version]}/src/#{bin}")) && File.read("#{node[:redis][:dir]}/bin/#{bin}") == File.read("/#{BASE}/src/redis-#{node[:redis][:version]}/src/#{bin}")
move_bins << "cp src/#{bin} #{node[:redis][:dir]}/bin/"
end
}
unless move_bins.size == 0
Bash "stop redis" do
code "/etc/init.d/redis stop"
#
# Cookbook Name:: redis
# Recipe:: source
#
# Author:: Gerhard Lazu (<gerhard.lazu@papercavalier.com>)
#
# Copyright 2010, Paper Cavalier, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
ssl on;
ssl_certificate /data/scommerce/shared/certificates/shop.vitrue.com.crt;
ssl_certificate_key /data/scommerce/shared/certificates/shop.vitrue.com.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:!LOW:!SSLv2:!EXPORT;