Skip to content

Instantly share code, notes, and snippets.

@zzondlo
zzondlo / nagios_lwrp_mock.rb
Created April 3, 2012 01:30 — forked from benjaminws/nagios_lwrp_mock.rb
Mock up of nagios LWRP
nagios_command "generic_queue_size" do
command "/path/to/check_rabbitmq_queue_size.pl"
arg_one {"queue_name" => String}
arg_two {"warning_size" => Integer}
arg_three {"critical_size" => Integer}
end
nagios_service "generic_queue_size" do
nagios_command_generic_queue_size do
queue_name "random_queue"
@zzondlo
zzondlo / version_set.rb
Created April 4, 2012 04:38 — forked from scottsbaldwin/version_set.rb
knife plugin to set data bag attribute
# This knife plugin provides the capability to set an attribute
# value in a data bag item. By default the 'versions' data bag
# is used, but that can be overridden with the -b option.
# Copy this file to ~/.chef/plugins/knife to install the plugin.
module KnifePlugins
class DataBagVersionSet < Chef::Knife
deps do
require 'chef/data_bag'
end
@zzondlo
zzondlo / gist:2297838
Created April 4, 2012 04:38 — forked from jtimberman/gist:1302749
bootstrap template that uses an encrypted data bag secret key
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /usr/bin/chef-client ]; then
apt-get update
apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
cd /tmp
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
tar zxf rubygems-1.6.2.tgz
cd rubygems-1.6.2
require "chef/config"
require "chef/knife"
require "chef/log"
require "chef/mixin/convert_to_class_name"
module DataBagCommon
def self.included(base)
base.module_eval do
def read_secret
@zzondlo
zzondlo / knife.rb
Created April 5, 2012 19:34 — forked from jtimberman/knife.rb
Commented knife.rb for all the things
# Knife Configuration File.
#
# This is a Ruby DSL to set configuration parameters for Knife's
# general options. The default location for this file is
# ~/.chef/knife.rb. If multiple Chef repositories are used,
# per-repository configuration files can be created. A per repository
# configuration file must be .chef/knife.rb in the base directory of
# the Chef repository. For example,
#
# ~/Development/chef-repo/.chef/knife.rb
#!/bin/bash
NODENAME="%farm_name%-%friendly_name%-%instance_id%"
LOG=/var/log/chef-bootstrap.log
DIRECTORY=/etc/chef
CLIENT_RB=$DIRECTORY/client.rb
CHEF_JSON=$DIRECTORY/chef.default.json
PRIVATE_KEY=$HOME/.ssh/id_rsa
PUBLIC_KEY=$PRIVATE_KEY.pub
function say_start {
@zzondlo
zzondlo / gist:2314987
Created April 5, 2012 23:22 — forked from pcn/gist:1607780
Example grover cluster definition
cluster_type = 'Grover'
differentiator = 'test'
# cluster_name = "#{cluster_type}_#{differentiator}"
cluster_name = "Grover"
require "Chef"
data = Chef::DataBagItem.load('cluster_template_values', cluster_type)['default']
ClusterChef.cluster cluster_name do
recipe "tuning"
#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'rubygems'
require 'thor'
require 'chef'
require 'chef/node'
require 'chef/role'
require 'chef/data_bag'
@zzondlo
zzondlo / update_sources_list.rb
Created April 7, 2012 14:45 — forked from juanje/update_sources_list.rb
Upada sources_list data_bag
#!/usr/bin/env ruby
require 'debsfromrepos'
require 'chef/config'
require 'chef/data_bag'
Chef::Config.from_file('./.chef/knife.rb')
data_bag = 'sources_list'
@zzondlo
zzondlo / test-my_app.json
Created April 7, 2012 14:46 — forked from ffaerber/test-my_app.json
test data-bag file for private repo on github
{
"id": "my_app",
"server_roles": [
"my_app"
],
"type": {
"my_app": [
"rails",
"unicorn"