How to point a chef client to a different chef server

I have set up a chef client on my computer to practice using the labs offered by learnchef.com.

How do I now point my chef to our internal chef servers (we have 2 non-production and production). Do I need to reconfigure knife.rb

and also create files validator.pem

and client.pem

?

+3


source to share


3 answers


You will need to get validator.pem from each server and register for each. Another option is to create a client on each server and store the private key.

To load other nodes, you need a validator.pem file for each server.

I am using the same use case and doing the following:

1) create a directory on the chef server that has knife.rb, client.pem, etc. ie:

c:\chef\confs\server1
c:\chef\confs\server2

      

2) set the environment variable KNIFE_HOME to the directory corresponding to the server you want to target



set KNIFE_HOME=c:\chef\confs\server1

      

Now every knife command will target server1.

Another option is to set whatever environment variable you want and use it in the knife.rb file, for example chef_server_url ENV ['CHEF_SERVER_I_USE']

But this latter involves changing some other parameters (for example, using server1.pem and server2.pem files and using ENV [] in validator_key for example)

You can find an example of this method here (for users, but easy to adapt): http://docs.getchef.com/config_rb_knife.html

+2


source


Your chef client doesn't have to talk to multiple chef servers. If you want to switch chef servers, then simply delete the existing chef client configuration and make a fresh bootstrap:

ssh $VM rm -rf /etc/chef
knife bootstrap $VM ...

      



Your chef's workstation (your development machine that administers the chef's servers) may want to access more than one chef server. In this case, I recommend installing a plug -in knife block .

0


source


For a one-time interaction, you can use an option -s SERVER_URL

, for example:

chef-client -S 'http://my_chef_server.net'

      

If you need to constantly change Chef Server, you need to edit the file knife.rb

. To interact with Chef Server, three configuration parameters are required and you must change them.

node_name
client_key
chef_server_url

      

You can do this using a command knife configure

or manually using a text editor (by default, it is located in ~ / .chef / knife.rb).

I would advise you to familiarize yourself with this fact. This is Commented knife.rb for all things . I believe this will help you learn all about knife tuning.

0


source







All Articles