Skip to content

Instantly share code, notes, and snippets.

View mattray's full-sized avatar
🇦🇺
in Sydney

Matt Ray mattray

🇦🇺
in Sydney
View GitHub Profile
#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end
@jtimberman
jtimberman / gist:548261
Created August 24, 2010 20:32
preseed.cfg for automated installations with chef from apt.opscode.com
# This is the entire preseed config file used on an example Lucid system. See the preseed
# documentation for more information on the options here. This will use US English by default.
#
# https://help.ubuntu.com/10.04/installation-guide/amd64/preseed-contents.html
#
# This preseed will automatically install Ubuntu 10.04 with default options. Understand what
# it is doing before you use it.
#
# Boot Options line:
#
#!/usr/bin/env ruby
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info
Chef::Log.level(:info)
Vagrant::Config.run do |global_config|
aptdir = (ENV['APTCACHE'] or "#{ENV['HOME']}/aptcache/")
checkout = (ENV['COOKBOOKS'] or "#{ENV['HOME']}/openstack-cookbooks")
ip_prefix = (ENV['IP_PREFIX'] or "192.168.76.")
mac_prefix = (ENV['MAC_PREFIX'] or "080027076")
fixed = (ENV['FIXED'] or "10.0.76.0/24")
global_config.vm.define :chef do |config|
suffix = "100"
ip = "#{ip_prefix}#{suffix}"
config.vm.box = "base"
@jtimberman
jtimberman / gist:828427
Created February 15, 2011 22:42 — forked from Atalanta/gist:828351
way to parse knife exec options
require 'awesome_print'
require 'trollop'
def convert_input(arguments)
arguments.reject do |option|
option !~ /^[a-z]+:[a-z]{2,}-*[a-z]*-*\d*$/
end.map do |option|
opt, value = option.split(':')
[ '--' + opt, value ]
end.flatten
@jtimberman
jtimberman / workstation_emacs.rb
Created March 8, 2011 03:00
automate installation of Emacs.app
[Mon, 07 Mar 2011 20:38:02 -0700] INFO: Starting Chef Run (Version 0.9.14)
[Mon, 07 Mar 2011 20:40:02 -0700] INFO: remote_file[/Users/jtimberman/.chef/cache/Emacs.dmg]: Creating /Users/jtimberman/.chef/cache/Emacs.dmg
[Mon, 07 Mar 2011 20:40:04 -0700] INFO: Ran execute[hdid /Users/jtimberman/.chef/cache/Emacs.dmg] successfully
[Mon, 07 Mar 2011 20:40:08 -0700] INFO: Ran execute[cp -r '/Volumes/Emacs/Emacs.app' '/Applications'] successfully
[Mon, 07 Mar 2011 20:40:09 -0700] INFO: Ran execute[hdiutil detach '/Volumes/Emacs'] successfully
[Mon, 07 Mar 2011 20:40:22 -0700] INFO: Chef Run complete in 140.384327 seconds
[Mon, 07 Mar 2011 20:40:22 -0700] INFO: cleaning the checksum cache
[Mon, 07 Mar 2011 20:40:22 -0700] INFO: Running report handlers
[Mon, 07 Mar 2011 20:40:22 -0700] INFO: Report handlers complete
Chef::Log.level = :debug
# your recipe
Chef::Log.level = Chef::Config[:log_level]
# Use Chef resources in an application via solo mode.
# Could also be configured in client mode, and then use a server.
require 'rubygems'
require 'chef'
require 'chef/client'
require 'chef/run_context'
Chef::Config[:solo] = true
Chef::Config[:log_level] = :info

Start a feature branch based off the develop branch and do your changes.

git flow feature start some_new_things

Bump the version number of each cookbook you work on, major numbers are for api changes, minor numbers are for new features and release numbers are for bugfixes.

Environment files are where we control the version of cookbooks that run

@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")