I have just started working with Chef, and I am quite new to to the DevOps field.
I installed Chef Server, it worked fine, then I started playing with Knife a little bit and added two clients - my MacBook (OS X) and an Ubuntu 10.04 server that I don't manage myself, so I had to ask a sysadmin to install chef-client to this machine. I created a test cookbook and added it to the run-lists of each client. However, when I tried to run chef-client on both of them, on my Mac OS X machine everything worked fine, while the Ubuntu 10.04 run was throwing an error:
$ sudo chef-client
[Wed, 17 Apr 2013 16:32:26 +0200] INFO: Starting Chef Run (Version 0.9.18)
[Wed, 17 Apr 2013 16:32:27 +0200] ERROR: Running exception handlers
[Wed, 17 Apr 2013 16:32:27 +0200] ERROR: Exception handlers complete
/usr/lib/ruby/1.8/net/http.rb:2101:in `error!': 404 "Object Not Found" (Net::HTTPServerException)
from /usr/lib/ruby/1.8/chef/rest.rb:234:in `api_request'
from /usr/lib/ruby/1.8/chef/rest.rb:285:in `retriable_rest_request'
from /usr/lib/ruby/1.8/chef/rest.rb:215:in `api_request'
from /usr/lib/ruby/1.8/chef/rest.rb:226:in `api_request'
from /usr/lib/ruby/1.8/chef/rest.rb:335:in `follow_redirect'
from /usr/lib/ruby/1.8/chef/rest.rb:226:in `api_request'
from /usr/lib/ruby/1.8/chef/rest.rb:285:in `retriable_rest_request'
from /usr/lib/ruby/1.8/chef/rest.rb:215:in `api_request'
from /usr/lib/ruby/1.8/chef/rest.rb:111:in `get_rest'
from /usr/lib/ruby/1.8/chef/client.rb:252:in `sync_cookbooks'
from /usr/lib/ruby/1.8/chef/client.rb:165:in `run'
from /usr/lib/ruby/1.8/chef/application/client.rb:222:in `run_application'
from /usr/lib/ruby/1.8/chef/application/client.rb:212:in `loop'
from /usr/lib/ruby/1.8/chef/application/client.rb:212:in `run_application'
from /usr/lib/ruby/1.8/chef/application.rb:62:in `run'
from /usr/bin/chef-client:26
The error looks quite general, so it doesn't help too much to figure out what is the cause.
Short answer: make sure you have installed the last version of Chef Client.
Long answer:
The first thing to do in order to get more details is enabling a better logging in the client.rb file. Usually you do that by adding to /etc/chef/client.rb the following line:
log_level :debug
That already showed me what resource the client was trying to access:
[Wed, 17 Apr 2013 16:46:10 +0200] DEBUG: Sending HTTP Request via GET to
chef.xxxxxx.xxxxx.com:443/nodes/node-apache1.xxxxxx.com/cookbooks
[Wed, 17 Apr 2013 16:46:10 +0200] ERROR: Running exception handlers
[Wed, 17 Apr 2013 16:46:10 +0200] ERROR: Exception handlers complete
[Wed, 17 Apr 2013 16:46:10 +0200] DEBUG: Re-raising exception:
Net::HTTPServerException - 404 "Object Not Found"
It was a non-existent resource because the sysadmin had installed the client from Opscode's Ubuntu repo and this one wasn't the last version of it, and it was incompatible with Chef Server 11. I asked him to install the latest version of the client from the Chef Client install page on Opscode.com
As you can see there, you can either download the desired package or just run
curl -L https://www.opscode.com/chef/install.sh | sudo bash
for the latest version.
Running chef-client works all right now.
PS: I am not sure this will help others or not but I managed to resolve this same issue in the following way.
If you ssh into the box and then run this command
sudo chef-client --runlist "your_cookbook_name"
it will prompt the exact error. So you can take action according to the error.
BDW in my case, when I checked through above method. I found that I didn't create the Environment
in https://manage.chef.io/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With