Skip to content

Instantly share code, notes, and snippets.

Chef::ShellOut.new("nmap").run_command.stdout.each do |line|
# .. parse line ..
normal[:some_attr] = "whatevs"
end
ruby_block "cryptosetup" do
block do
Chef::Mixin::Command.popen4("cryptosetup") do |p, i, o, e|
i.puts "Your stdin"
i.close
end
end
end
<%= File.open("/your/file").gets %>
service "mysql" do
action :start
ping :node, "role:webserver", { :run_list => "boink" }
end
r = gem_package "your_library" do
version "1.2.2"
action :nothing
end
r.run_action(:install)
r = gem_package "your_library" do
version "1.2.2"
action :nothing
end
r.run_action(:install)
require 'chef'
require 'chef/data_bag'
require 'chef/data_bag_item'
bag = Chef::DataBag.load("yourbag")
# The "true" here just inflates them to the data bag items
bag.list(true).each do |item|
item["poop"] = "smith"
item.save
end
# Will only work for resources that appear *after* this one in the run list
ruby_block "foo" do
block do
r = resources(:service => "bar")
r.action :stop
end
end
# Will actually stop itself
service "bar" do
(software "ree" :source "ruby-enterprise-1.8.7-2010.02"
:steps [["bash" "-c" "cd ./source/distro/google-perftools-1.4 && ./configure --prefix=/opt/opscode/embedded --disable-dependency-tracking && make libtcmalloc_minimal.la"]
["sudo" "mkdir" "-p" "/opt/opscode/embedded/lib"]
["sudo" "bash" "-c" (str "cp -Rpf " (cond (is-os? "darwin") "./source/distro/google-perftools-1.4/.libs/libtcmalloc_minimal.*"
(is-os? "linux") "./source/distro/google-perftools-1.4/.libs/libtcmalloc_minimal.*") " /opt/opscode/embedded/lib")]
["bash" "-c" "cd ./source && ./configure --prefix=/opt/opscode/embedded --enable-mbari-api CFLAGS='-g -O2' --with-opt-dir=/opt/opscode/embedded"]
["bash" "-c"
(cond (is-os? "darwin") "cd ./source && make PRELIBS=\"-Wl,-rpath,/opt/opscode/embedded/lib -L/opt/opscode/embedded/lib -lsystem_allocator -ltcmalloc_minimal\""
(project "chef-full" [ "zlib" "libiconv" "db" "gdbm" "ncurses" "openssl" "libxml2" "libxslt" "ruby" "chef" ])