Skip to content

Instantly share code, notes, and snippets.

@zzondlo
Forked from fnichol/knife.rb
Created February 23, 2012 03:07
Show Gist options
  • Select an option

  • Save zzondlo/1889718 to your computer and use it in GitHub Desktop.

Select an option

Save zzondlo/1889718 to your computer and use it in GitHub Desktop.
My Generic knife.rb
current_dir = File.dirname(__FILE__)
home_dir = ENV['HOME']
user = ENV['OPSCODE_USER'] || ENV['USER']
orgname = ENV['ORGNAME']
server_url = ENV['CHEF_SERVER'] || "https://api.opscode.com/organizations/#{orgname}"
key = "#{home_dir}/.chef.d/#{user}.pem"
val_key = "#{home_dir}/.chef.d/#{orgname}-validator.pem"
# path to cookbooks
cookbook_path ["#{current_dir}/../cookbooks"]
# logging details
log_level :info
log_location STDOUT
# user/client and private key to authenticate to a chef server, if needed
node_name user
client_key key if File.exists?(key)
# if an orgname is given, then we want to talk to a chef server
if orgname
validation_client_name "#{orgname}-validator"
validation_key val_key if File.exists?(val_key)
chef_server_url chef_server
end
# caching options
cache_type 'BasicFile'
cache_options( :path => "#{home_dir}/.chef/checksums" )
# new cookbook defaults
cookbook_copyright ENV['COOKBOOK_COPYRIGHT'] || %x{git config --get user.name}.chomp
cookbook_email ENV['COOKBOOK_EMAIL'] || %x{git config --get user.email}.chomp
cookbook_license "apachev2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment