[chef] Re: How to target different servers/client-keys using knife?


Chronological Thread 
  • From: Bryan McLellan < >
  • To:
  • Subject: [chef] Re: How to target different servers/client-keys using knife?
  • Date: Tue, 19 Oct 2010 15:52:39 -0700

On Tue, Oct 19, 2010 at 3:34 PM, Mike Williams
< >
 wrote:
> On 20/10/2010, at 06:20 , Alex Soto wrote:
>> I also have my knife config determine what branch I'm on and configure the 
>> knife client to communicate with the corresponding server, setup correct 
>> keys, etc.
>
> That sounds interesting.  How do you do that?  Have you got any code you 
> can share?

Here's what some of us do at Opscode using a directory structure:

mkdir ~/platform # create a base directory
cd ~/platform
git clone git://github.com/opscode/chef-repo.git  ORGANIZATION
mkdir ORGANIZATION/.chef
cp /path/to/YOUR_KEY.pem ORGANIZATION/.chef/$USER.pem
cp /path/to/ORGANIZATION-validator.pem
ORGANIZATION/.chef/ORGANIZATION-validator.pem

cat > ORGANIZATION/.chef/knife.rb << EOF
config_dir = File.dirname(__FILE__)
cookbook_dir = File.join(config_dir, ".." ,"cookbooks")
organization = 
File.basename(File.expand_path(File.join(File.dirname(__FILE__),
"..")))

log_level        :info
log_location     STDOUT
node_name        ENV['USER']
client_key       "#{config_dir}/#{ENV['USER']}.pem"
chef_server_url  "https://api.opscode.com/organizations/#{organization}";
cache_type       'BasicFile'
cache_options( :path => "#{config_dir}/checksums" )
cookbook_path [ cookbook_dir ]

validation_client_name "#{organization}-validator"
validation_key "#{config_dir}/#{organization}-validator.pem"
EOF

repeat this process for each organization, which allows you to switch
organizations by changing between the directories in a tree like:

platform/
platform/sprocket-prod/
platform/sprocket-preprod/
platform/personal-barnacles/
platform/sandbox-of-dewm/

Of course this is setup for using the platform using the directory
structure as a variable, but the knife configuration file is ruby so
you can choose different chef_server_urls than the platform based on
other factors.

Bryan



Archive powered by MHonArc 2.6.16.

§