Reputation: 71
I've set up a chef client on my computer in order to do practice using the labs offered by learnchef.com.
How do I now point my chef client to our internal chef servers( we have 2 non-production and production). Do you need to reconfigure knife.rb
as well as recreate validator.pem
and client.pem
files?
Upvotes: 4
Views: 3673
Reputation: 576
For single-time interaction you may use -s SERVER_URL
option like:
chef-client -S 'http://my_chef_server.net'
In case you need to change Chef Server forever, you have to edit knife.rb
file. In order to interact with a Chef Server, three configuration settings are required, and you must change them.
node_name
client_key
chef_server_url
You may do it using knife configure
command or manually with text editor(by default it lies in ~/.chef/knife.rb).
I would advise to you get familiar with that gist. It's Commented knife.rb for all the things. I believe it will help you to find out everything about configuring knife.
Upvotes: 0
Reputation: 77941
Your chef client does not need to talk to more than one chef server. If you want to switch chef servers, then just delete the chef client's existing configuration and do a fresh bootstrap:
ssh $VM rm -rf /etc/chef
knife bootstrap $VM ...
Your chef workstation (your development machine that administers the chef servers) might want to access more than one chef server. In that case I recommend installing the knife block plugin.
Upvotes: 0
Reputation: 15784
You'll have to get the validator.pem from each server and register to each Another option is to create a client on each server and save the private key.
For bootstraping other nodes you need the validator.pem file for each server.
I've the same use case and do the following:
1) create a directory per chef server containing a knife.rb, client.pem etc. i.e:
c:\chef\confs\server1
c:\chef\confs\server2
2) set KNIFE_HOME environment variable to the directory matching the server you wish to target
set KNIFE_HOME=c:\chef\confs\server1
Now every knife command will target server1.
Another option is to set any environment variable you wish and use it in your knife.rb file like chef_server_url ENV['CHEF_SERVER_I_USE']
But this last one involves having some other settings modified (like using server1.pem and server2.pem files and using the ENV[] in the validator_key for exemple)
You can find an exemple of this method here (for users, but easy to adapt): http://docs.getchef.com/config_rb_knife.html
Upvotes: 2