Skip to content

Instantly share code, notes, and snippets.

Ohai.plugin(:Mdadm) do
provides 'mdadm'
def create_raid_device_mash(stdout)
device_mash = Mash.new
device_mash[:device_counts] = Mash.new
stdout.each do |line|
case line
when /Version\s+: ([0-9.]+)/
device_mash[:version] = Regexp.last_match[1].to_f
@btm
btm / gist:5086184
Last active December 14, 2015 12:28 — forked from maplebed/gist:5086156
# If the host has ganglia in the run_list, install the mongo plugin
# In Chef 11 node.recipe? returns true for the run_list and expanded_runlist (node[:recipes])
# In Chef 10 node.recipe? returns true for the run_list and already loaded recipes (seen_recipes)
# -- I believe on Chef 10 node.recipe? does not evaluated the expanded run_list so you want node[:recipes] too
if node.recipe?("ganglia::default") or node[:recipes].include?("ganglia::default")
# Make sure we've already executed the ganglia recipe in this run to get the ganglia_python LWRP
include_recipe "ganglia::default"
ganglia_python "mongodb" do
action :enable
end
@btm
btm / gist:4073447
Created November 14, 2012 17:19 — forked from anonymous/gist:3984352
def configure_session
list = case config[:manual]
when true
@name_args[0].split(" ")
when false
r = Array.new
q = Chef::Search::Query.new
@action_nodes = q.search(:node, @name_args[0])[0]
@action_nodes.each do |item|
# we should skip the loop to next iteration if the item returned by the search is nil
@btm
btm / gist:1877351
Created February 21, 2012 16:54 — forked from anonymous/gist:1877335
Recipe
if platform?("ubuntu")
bash "add_mehnat" do
code <<-EOH
echo 'deb http://packages.mehnat.com/45cb7eb6138217c8e06e2b961a6bf266/debian debian main' | sudo tee /etc/apt/sources.list.d/mehnat.list > /dev/null
curl http://packages.mehnat.com/mehnat.packages.key | sudo apt-key add -
sudo apt-get update
EOH
end
end
About the test system (debian5test):
$ cat /etc/debian_version
5.0.2
$ dpkg -l stompserver libnet-stomp-perl perl ruby
ii libnet-stomp-perl 0.34-1 A Streaming Text Orientated Messaging Protocol Client
ii perl 5.10.0-24 Larry Wall's Practical Extraction and Report Language
ii ruby 4.2 An interpreter of object-oriented scripting language Ruby
ii stompserver 0.9.9-1 a stomp messaging server implemented in ruby
Installing Ohai on Windows:
Install Ruby via one-click installer (I used ruby186-27_rc)
http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe
Start the RubyGems Package Manager
Programs -> Ruby-186-27 -> RubyGems -> RubyGems Package Manager
Add gems.opscode.com to gem sources.
C:\Ruby>gem sources -a http://gems.opscode.com
require 'rubygems'
require 'nokogiri'
require 'json'
minimal = {
'name' => 'minimal_vm',
'memory' => 512,
'hd' => '/var/lib/libvirt/images/fc10-x86-64-xen.img',
'cdrom' => '/home/bb/os_images/Fedora-10-x86_64-DVD.iso',
'boot' => ['hd', 'cdrom']
service "apache2" do
name value_for_platform(
[ "CentOS", "RedHat", "Fedora", "SuSE" ] => { "default" => "httpd" },
"Debian" => { "default" => "apache2" },
"Ubuntu" => { "default" => "apache2", "8.10" => "apache2_lolz" }
)
supports :restart => true
action :enable
end