Skip to content

Instantly share code, notes, and snippets.

@apsoto
Created November 22, 2010 19:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apsoto/710473 to your computer and use it in GitHub Desktop.
Save apsoto/710473 to your computer and use it in GitHub Desktop.
Managing different chef environments using git branches
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' )
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment