Skip to content

Instantly share code, notes, and snippets.

@rottenbytes
rottenbytes / chef-resource.rb
Created March 11, 2011 19:01
Generic client
module MCollective
module Agent
# An agent that uses Opscode to manage resources
# Original credit goes to R.I. Pienaar
class Chefresource<RPC::Agent
metadata :name => "SimpleRPC Chef Resource Agent",
:description => "Generic resource management",
:author => "Nicolas Szalay <nico@rottenbytes.info>",
:license => "BSD",
:version => "1.0",
module MCollective
module Agent
class agentreload<RPC::Agent
action 'reload' do
validate :name, String
reply.fail! "#{request[:name]} not found." unless Agents.agentlist.include?(request[:name])
# we should iterate on @config.libdir here...
load(@config.libdir[0]+"/mcollective/agent/"+request[:name]+".rb")
end
@rottenbytes
rottenbytes / gist:1106603
Created July 26, 2011 12:05 — forked from tfheen/gist:780086
fixed the case where node has checked in less than 60 seconds ago
#! /usr/bin/env ruby
# Original by Tollef Fog Heen <tfheen _at_ err.no>
require 'chef/config'
require 'chef/search/query'
require 'chef/log'
require 'time'
require 'getoptlong'
require "ohai"
@rottenbytes
rottenbytes / graphdeps.rb
Created September 6, 2011 07:23
Graph your cookbooks deps
#!/usr/bin/env ruby
cbdir=ARGV[0]
output = "./deps.dot"
puts "Running on #{cbdir}..."
cb_meta = Dir.glob("#{cbdir}/*/metadata.rb")
fp=File.open(output,"w")
@rottenbytes
rottenbytes / nodes.erl
Created September 23, 2011 13:15 — forked from videlalvaro/nodes.erl
Find Erlang nodes in the cluster
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname nodefinder
%% Usage:
%% chmod +x nodes.erl
%% ./nodes.erl 'somenode@host'
main([N]) ->
Node = list_to_atom(N),
@rottenbytes
rottenbytes / cookbooks-tests-libraries-noah.rb
Created October 23, 2011 18:21
Integrating noah into chef
module Noah
def noah_get_host(hostname)
require "net/http"
require "json"
noah_server="http://10.251.12.10:9292"
url = URI.parse("#{noah_server}/hosts/#{hostname}")
req = Net::HTTP::Get.new(url.path)
resp = Net::HTTP.new(url.host, url.port).start do |http|
#
# Cookbook Name:: haproxy
# Recipe:: default
# Author:: Joe Williams <joe@joetify.com>
package "haproxy" do
action :install
end
haproxy_templates = [ "global", "defaults", "frontend", "SOMEBACKEND" ]
@rottenbytes
rottenbytes / ideal ops.md
Created May 28, 2012 13:53 — forked from bhenerey/ideal ops.md
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

@rottenbytes
rottenbytes / caching.diff
Created June 21, 2012 08:35
Add caching to @opscode/chef-rundeck
diff --git a/bin/chef-rundeck b/bin/chef-rundeck
index 5ea22d7..b665ca5 100755
--- a/bin/chef-rundeck
+++ b/bin/chef-rundeck
@@ -46,6 +46,12 @@ class ChefRundeckCLI
:long => "--port PORT",
:description => "The port to run on, default 9980",
:default => 9980
+
+ option :cache_file,
@rottenbytes
rottenbytes / redmine_css.js
Created July 3, 2012 10:05
Grease monkey to change CSS in redmine/chiliproject
// ==UserScript==
// @name Redmine color change
// @namespace nico
// @description Change CSS in redmine
// @include https://XXXXX*
// @version 1
// ==/UserScript==
function addCss(cssString) {