Skip to content

Instantly share code, notes, and snippets.

@jbz
Created February 16, 2011 17:08
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jbz/829733 to your computer and use it in GitHub Desktop.
Save jbz/829733 to your computer and use it in GitHub Desktop.
knife.rb that switches Opscode orgs/validators based on git branch
# This knife.rb orig. provided by jtimberman@opscode.com - but any mistakes are mine!
current_dir = File.dirname(__FILE__)
platform = "https://api.opscode.com/organizations"
require 'grit'
branch = Grit::Repo.new("#{current_dir}/..").head.name
case branch
when "dev"
orgname = "ourfirm-dev"
url = "#{platform}/#{orgname}"
when "test"
orgname = "ourfirm-test"
url = "#{platform}/#{orgname}"
when "production"
orgname = "ourfirm-production"
url = "#{platform}/#{orgname}"
end
validation_key "#{current_dir}/#{orgname}-validator.pem"
chef_server_url url
log_level :info
log_location STDOUT
node_name "<<username>>"
client_key "#{current_dir}/<<username>>.pem"
validation_client_name "#{orgname}-validator"
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path ["#{current_dir}/../cookbooks"]
cookbook_copyright "Our Company, Inc."
cookbook_license "apachev2"
cookbook_email "cookbooks@ourfirm.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment