Skip to content

Instantly share code, notes, and snippets.

@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|
@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 / 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 / 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"
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 / 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 <[email protected]>",
:license => "BSD",
:version => "1.0",