This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |