How to install and configure Chef Client

Chef-logoIn my previous post I have described about Chef and “How to install and configure Chef Server“. In this article I will show you how to install and configure Chef client. As per Opscode: The chef-client relies on abstract definitions (known as cookbooks and recipes) that are written in Ruby and are managed like source code. Each definition describes how a specific part of your infrastructure should be built and managed. The chef-client then applies those definitions to servers and applications, as specified, resulting in a fully automated infrastructure. When a new node is brought online, the only thing the chef-client needs to know is which cookbooks and recipes to apply.

Installing Chef Client:

To install Chef Client on a machine go to the URL Select your Operating System, Version and Environment. It will show you the link to download the relevant package.

On Linux you can also install through the installer script. The script will download and install the latest version of chef client on your machine.

After finishing the installation verify that the chef-client was installed. If you have RVM installed on your machine then don’t forgot to change the ruby to system ruby issue the command rvm use system

For me the result looks like this.

You can find a folder structure like below on your machine after chef-client installation.

Now we will start working to communicate with our chef server. To communicate with chef server follow the below steps.

Create a directory named chef inside the /etc  directory.

We need to copy the  chef-validator.pem  file from our chef server. You can find this file in  /etc/chef  directory of the server. Issue the below command to copy it to our client machine.

Now we need a  client.rb  file in the client machine in which we have to mention about our chef server.

Append the below code to the file

Finally we need to register the client with the chef server. Issue the below command to register the client in chef server.

Login to the chef server URL and now you can able to see the newly installed client machine name in the client and node list of the chef server. Now you can run any role or recipes on the client. Below is an example to run a role on the client machine.

Create a joson file inside the  /etc/chef  directory named startup.json

Append the below code to run a role

Issue the below command to execute the role on the client machine.

That’s it. Enjoy with your newly installed Chef Server and client.

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

13 thoughts on “How to install and configure Chef Client

  1. It was surprisingly difficult to find a non-bootstrap, non-aws oriented example. This was a really clear, helpful explanation. Thanks!!!

  2. # /usr/bin/chef-client -j /etc/chef/startup.json
    [2015-02-23T18:24:04+05:30] INFO: Forking chef instance to converge…
    Starting Chef Client, version 12.0.3
    [2015-02-23T18:24:04+05:30] INFO: *** Chef 12.0.3 ***
    [2015-02-23T18:24:04+05:30] INFO: Chef-client pid: 2936
    Creating a new client identity for chef-client using the validator key.
    [2015-02-23T18:24:45+05:30] INFO: Client key /etc/chef/client.pem is not present – registering
    [2015-02-23T18:24:46+05:30] ERROR: SSL Validation failure connecting to host: – SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

    Chef encountered an error attempting to create the client “chef-client”

    [2015-02-23T18:24:46+05:30] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
    Chef Client failed. 0 resources updated in 41.443313834 seconds
    [2015-02-23T18:24:46+05:30] ERROR: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    [2015-02-23T18:24:46+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

        • But as per the error message you given earlier chef-client is complaining for the client.pem.
          [2015-02-23T18:24:45+05:30] INFO: Client key /etc/chef/client.pem is not present Please validate again that you putted your client.pem file in that location /etc/chef otherwise modify the client.rb file and append the client.pem key path. Let me know if the problem still persist.

    • Hi, Sorry for the late reply. You should get the validation key after creating your organization. If you lost or forgot that key then you can simply recreate that key using Reset Validation Key option.


Leave a Reply