Skip to content

Instantly share code, notes, and snippets.

@zzondlo
zzondlo / dna.json
Created February 23, 2012 02:48 — forked from fnichol/dna.json
Example webapp server configured with chef-solo dna.json
{
"webapp": {
"web_server": "apache2",
"vhosts": [
{ "id": "production",
"host_name": "main.example.com",
"non_ssl_server": true,
"www_redirect": false,
"ssl_server": true,
"ssl_www_redirect": false
@atomic-penguin
atomic-penguin / base5.rb
Created October 18, 2011 15:09
chef-baseline-role-example
name "base5"
description "Contains run list of roles which are safe to run on all RHEL5 and RHEL6 servers."
override_attributes "inittab" => {
"runlevel" => "3"
},
"chef_client" => {
"server_url" => "http://chef.example.com:4000",
"init_style" => "init"
},
"logwatch" => {
@jtimberman
jtimberman / data_bags_apache_stuff.json
Created October 17, 2011 20:29
goes in chef-repo/data_bags/apache/
{
"id": "stuff",
"admin_address": {
"_default": "noone@example.com",
"production": "root@example.com",
"development": "devs@example.com",
}
}
@jtimberman
jtimberman / chef-ec2.rake
Created September 7, 2011 03:24 — forked from apsoto/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'
users_manage "sysadmin" do
data_bag "users"
search_group "sysadmin"
group_name "sysadmin"
group_id 2000
end
@jtimberman
jtimberman / gist:796807
Created January 26, 2011 15:12
run these in shef in the main context
# show the expanded run_list (expands included roles if any):
chef > roles.show(“webserver”).run_list.expand
chef > roles.show(“webserver”).run_list.expand.roles
chef > roles.show(“webserver”).run_list.expand.recipes
@danielsdeleo
danielsdeleo / dynamically_add_handler.rb
Created November 12, 2010 17:33
add an exception/report handler from inside a recipe
p = gem_package("nomnomnom-client") { action :nothing }
p.run_action(:install)
Gem.clear_paths
require 'nom_nom_nom'
nomnomnom_servers = []
search(:node, "role:nomnomnom-server") do |server|
nomnomnom_servers << server[:ipaddress]
end
resource def file (in recipe test for time being)
#based on deploy resource; didnt use lwrp because had to pass in a block
def initialize(name, collection=nil, node=nil)
super(name, collection, node)
@resource_name = :test_nested
@action = "create"
@allowed_actions.push(:create)
end
@seancribbs
seancribbs / autoconf.rb
Created June 24, 2009 00:11
Definition and library for Chef, allowing automatic installation of packages from source tarballs.
module Autoconf
extend self
def switches(config=nil)
case config
when String
switch(config)
when Enumerable
config.map {|item| switch(item) }.join(" ").strip
else