Created
July 20, 2015 15:12
-
-
Save giuliocalzolari/8505b0bc9c99e2008b81 to your computer and use it in GitHub Desktop.
Multiple Knife configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adaptive knife.rb | |
def colorize(text, color_code) | |
"\e[#{color_code}m#{text}\e[0m" | |
end | |
def red(text); colorize(text, 31); end | |
def green(text); colorize(text, 32); end | |
DEF_OPSORGNAME = "demo-org" | |
if ENV['OPSORGNAME'].nil? | |
OPSORGNAME = "#{DEF_OPSORGNAME}" | |
puts red("OPSORGNAME is not defined") | |
puts red(" export OPSORGNAME=#{OPSORGNAME}") | |
elsif ENV['OPSORGNAME'] == "" | |
OPSORGNAME = "#{DEF_OPSORGNAME}" | |
puts red("OPSORGNAME is empty") | |
puts red(" export OPSORGNAME=#{OPSORGNAME}") | |
else | |
OPSORGNAME = ENV['OPSORGNAME'] | |
puts green("OPSORGNAME is defined: #{OPSORGNAME}") | |
puts green(" export OPSORGNAME=#{OPSORGNAME}") | |
end | |
log_level :info | |
log_location STDOUT | |
node_name 'giuliocalzo' | |
client_key "~/.chef/user-#{OPSORGNAME}.pem" | |
validation_client_name "chef-validator" | |
validation_key "~/.chef/validator-#{OPSORGNAME}.pem" | |
if File.file?("knife-#{OPSORGNAME}.rb") | |
chef_server_url = "" | |
eval File.open("knife-#{OPSORGNAME}.rb").read | |
else | |
puts red("ERROR no file found knife-#{OPSORGNAME}.rb ") | |
chef_server_url "https://api.opscode.com/organizations/#{OPSORGNAME}.rb" | |
end | |
syntax_check_cache_path '~/.chef/syntax_check_cache' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment