Skip to content

Instantly share code, notes, and snippets.

View mdkent's full-sized avatar

Matthew Kent mdkent

  • Basecamp
  • Nanaimo, BC, Canada
View GitHub Profile
--- chef-client.init 2009-11-04 09:44:30.000000000 -0800
+++ ../SOURCES/chef-client.init 2009-12-17 15:06:37.000000000 -0800
@@ -17,8 +17,8 @@
pidfile=${PIDFILE-/var/run/chef/client.pid}
lockfile=${LOCKFILE-/var/lock/subsys/$prog}
config=${CONFIG-/etc/chef/client.rb}
-user=${USER-root}
-group=${GROUP-root}
+chef_user=${CHEF_USER-root}
+chef_group=${CHEF_GROUP-root}
# ec2 ami-1515f67c
sudo sed -i 's/universe/multiverse universe/' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert rubygems git-core rake librspec-ruby libxml-ruby thin couchdb zlib1g-dev libxml2-dev
sudo gem sources -a http://gems.opscode.com
sudo gem sources -a http://gemcutter.org # for nanite
sudo gem install cucumber merb-core nanite jeweler uuidtools json libxml-ruby --no-ri --no-rdoc
mkdir ~/src
cd ~/src
git clone git://github.com/opscode/chef.git
sname = "recipe[#{self.cookbook_name}" + (self.recipe_name == "default" ? "" : self.recipe_name) + "]"
if node.recipes[-1] != sname
node.recipes.remove sname
node.recipes << sname
end
collection.each do |r|
if r.class == Chef::Resource::Package
if r.action.to_s.include?("install") or r.action.to_s.include?("upgrade")
t = resources(:template => "/etc/pkgsync/musthave")
--- lib/deep_merge.rb.orig 2010-01-11 10:15:52.000000000 -0800
+++ lib/deep_merge.rb 2010-01-11 10:15:56.000000000 -0800
@@ -91,7 +91,7 @@
sort_merged_arrays = options[:sort_merged_arrays] || false
di = options[:debug_indent] || ''
# do nothing if source is nil
- if !source || (source.respond_to?(:blank?) && source.blank?) : return dest; end
+ if source.nil? || (source.respond_to?(:blank?) && source.blank?) : return dest; end
# if dest doesn't exist, then simply copy source to it
if !(dest) && overwrite_unmergeable : dest = source; return dest; end
irb(main):001:0> a = { :x => true }; b = { :x => false }; p a.deep_merge!(b, {:merge_debug => true})
Source class: Hash :: Dest class: Hash
Hashes: {:x=>false} :: {:x=>true}
looping: :x => false :: {:x=>true}
==>merging: :x => false :: true
Returning {:x=>true}
{:x=>true}
=> nil
with extlib loaded
irb(main):011:0> a = { :x => "test" }
=> {:x=>"test"}
irb(main):012:0> b = { :x => " " }
=> {:x=>" "}
irb(main):013:0> p a.deep_merge!(b)
{:x=>"test"}
=> nil
--- lib/deep_merge.rb.orig 2010-01-11 10:15:52.000000000 -0800
+++ lib/deep_merge.rb 2010-01-11 15:56:51.000000000 -0800
@@ -51,6 +51,8 @@
# Set to true to sort all arrays that are merged together
# :unpack_arrays DEFAULT: nil
# Set to string value to run "Array::join" then "String::split" against all arrays
+ # :check_for_blanks DEFAULT: false
+ # Use blank? as provided by extlib to help determine if data can be overwritten
# :merge_debug DEFAULT: false
# Set to true to get console output of merge process for debugging
# Chef Client Config File
require 'ohai'
require 'json'
o = Ohai::System.new
o.all_plugins
chef_config = JSON.parse(o[:ec2][:userdata])
if chef_config.kind_of?(Array)
chef_config = chef_config[o[:ec2][:ami_launch_index]]
class Chef
class Resource
class ManagedTemplate < Template
def initialize(name, collection=nil, node=nil)
super(name, collection, node)
not_if { ::File.exists?(name.sub(/(.*)(\/)/, '\1/noclobber.')) }
end
end
end
end
module SmartD
require "open3"
# Go through the devices in node[:block_device].
def self.pop_smartd_hash()
changed = false
node[:block_device].each do |device, properties|
if not node[:quick_start][:smartd].has_key?(device)