Sure, the idea is a knife.rb that evaluates a corresponding knife-config.BRANCHNAME.rb to override the config based on the git branch you are on. Great example of the design win of having ruby as the config language. You could DRY this up a bit, but this is version 1. Looking forward to any 'patches'. Alex .chef/knife.rb # Default to 'QA' environment validation_client_name 'channels-qa-validator' validation_key './.chef/channels-qa-validator.pem' chef_server_url 'https://api.opscode.com/organizations/channels-qa' cache_options( :path => './.chef/channels-qa-checksums' ) log_level :debug log_location STDOUT node_name 'apsoto' client_key '/Users/asoto/.chef/apsoto.pem' cache_type 'BasicFile' cookbook_path './cookbooks','./site-cookbooks' # Read in any environment specific config branch_cmd = %q{git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'} branch = `#{branch_cmd}`.strip environment_config = File.join(File.dirname(__FILE__), "knife-config.#{branch}.rb") if File.exists?(environment_config) eval(IO.read(environment_config)) Chef::Log.info("Loaded environment specific configuration from #{environment_config}") else Chef::Log.info("No environment specific config file found for branch #{branch}") end .chef/knife-config.master.rb log_level :info log_location STDOUT validation_client_name 'channels-qa-validator' validation_key './.chef/channels-qa-validator.pem' chef_server_url 'https://api.opscode.com/organizations/channels-qa' cache_options( :path => './.chef/channels-qa-checksums' ) .chef/knife-config.staging.rb log_level :debug log_location STDOUT validation_client_name 'channels-staging-validator' validation_key './.chef/channels-staging-validator.pem' chef_server_url 'https://api.opscode.com/organizations/channels-staging' cache_options( :path => './.chef/channels-staging-checksums' ) On Oct 19, 2010, at 3:34 PM, Mike Williams wrote:
|
Archive powered by MHonArc 2.6.16.