Skip to content

Instantly share code, notes, and snippets.

View rcreasey's full-sized avatar
🎯
Focusing

Ryan C. Creasey rcreasey

🎯
Focusing
View GitHub Profile
@rcreasey
rcreasey / solo_data_bags.rb
Created May 12, 2011 05:21
Using data bags with chef-solo
From: Brian Akins < brian@akins.org>
To: chef < chef@lists.opscode.com>
Subject: [chef] Data bag implementation for chef-solo
Date: Tue, 1 Feb 2011 10:42:05 -0500
We often use chef-solo for quick testing, etc. This is our extremely simple implementation of data bags for chef-solo. Add "data_bag_path /some/dir/data_bags" to your solo.rb and add this into your libraries:
if Chef::Config[:solo]
class Chef
module Mixin
module Language
@rcreasey
rcreasey / poweredbygamespy_com.json
Created May 19, 2011 19:34
Data Bag Deployment
{
"id": "poweredbygamespy_com",
"server_roles": ["gst-app-web"],
"type": {"gst-app-web": ["php_apache2"]},
"cookbook": "gst-app",
"repository": "git@github.com:gamespy-tech/site-pbg.git",
"revision": {"production": "v1.2", "staging": "develop", "development": "develop"},
"deploy_to": "/z/www/poweredbygamespy.com",
"php_modules": ["gd", "curl", "mysql"],
"force": {"production": false},
provides "gamespy"
require_plugin "kernel"
require_plugin "network"
def get_ip_address(name, eth)
network[:interfaces][eth][:addresses].each do |key, info|
gamespy[name] = key if info['family'] == 'inet'
end
end
begin
require 'mongo'
rescue LoadError
Chef::Log.warn("Missing gem 'mongo'")
%w{ mongo bson_ext }.each do |mongo_gem|
gem_install = gem_package mongo_gem do
action :nothing
end
gem_install.run_action(:install)
end
@rcreasey
rcreasey / graylog2.pill
Created July 18, 2011 15:51
Graylog2 Bluepill
Bluepill.application("graylog2", :log_file => "/var/log/bluepill/graylog2.log") do |app|
app.uid = "root"
app.gid = "root"
app.process("server") do |process|
process.working_dir = "/var/graylog2/server"
process.start_command = "/usr/bin/java -jar graylog2-server.jar -DconfigPath=/etc/graylog2.conf"
process.daemonize = true
process.start_grace_time = 10.seconds
@rcreasey
rcreasey / config-db_reader.rb
Created August 12, 2011 23:19
EM-Mongo and Goliath
config['mongo'] = EventMachine::Synchrony::ConnectionPool.new(size: 20) do
conn = EM::Mongo::Connection.new('localhost', 27017, 1, {:reconnect_in => 1})
conn.db('analytics')
end
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%} %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%} %{$fg[green]%}✔%{$reset_color%}"
setopt prompt_subst
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
RPS1="${return_code}"
PROMPT='%(?,%{%F{cyan}%},%{%F{red}%})%m:%{%F{white}%}%~ %{%F{gray}%}$(rvm_prompt_info)%{$reset_color%} $(git_prompt_info)%#%{$reset_color%} '
bash -c '
announce() {
echo ""
echo "*** $1 ***"
}
announce "Updating SSL CA's"
curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
announce "Installing Yum Repositories"
@rcreasey
rcreasey / chef-ec2.rake
Created September 7, 2011 03:57 — forked from jtimberman/chef-ec2.rake
Chef EC2 Node Cleanup task
namespace :ec2 do
# setup chef config
# assumes this file is sibling to .chef dir, ex: CHEF_REPO/tasks
config = File.join(File.dirname(__FILE__), '..', '.chef', 'knife.rb')
Chef::Config.from_file(config)
require 'active_support'
require 'aws'
desc 'Delete any ec2-based chef nodes that no longer exist'
class Parser
attr_accessor :logger
def initialize()
@logger = GELF::Notifier.new
end
def log_request( data )
@logger.notify!(:short_message => 'parsing data', :full_message => data.inspect)
end