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['KNIFE_USER'] || ENV['USER']
orgname = ENV['KNIFE_ORGNAME']
server_url = ENV['KNIFE_CHEF_SERVER']
chef_dir = "#{home_dir}/.chef.d"
key = "#{chef_dir}/#{user}.pem"
val_key = "#{chef_dir}/#{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 Opscode Hosted Chef Server
if orgname
validation_client_name "opscode-#{orgname}-validator"
validation_key val_key if File.exists?(val_key)
chef_server_url "https://api.opscode.com/organizations/#{orgname}"
end
# caching options
cache_type 'BasicFile'
cache_options( :path => "#{home_dir}/.chef/checksums" )
# new cookbook defaults
cookbook_copyright ENV['KNIFE_COOKBOOK_COPYRIGHT'] ||
%x{git config --get user.name}.chomp
cookbook_email ENV['KNIFE_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