Chef-client not updating a cookbook from the server

Solution 1:

There's a couple of things I can think of that might help you out.

  1. Verify that the cookbook version you are uploading is the most recent version

    A common problem with cookbook versioning is that you may be modifying cookbook version 1.0.0 locally and uploading, but the Chef Server has cookbook version 1.0.1 already uploaded to it. In that case, Chef Clients will typically retrieve the latest version (unless told otherwise) and your changes will never sync to the local cache.

    You can see all current versions of the cookbook on Chef Server via: knife cookbook show apache2

    One solution to this is the one you mentioned - increase your version number beyond what exists on Chef Server , i.e. 1.0.2 and upload.

    Another method is to remove any other apache2 cookbooks from Chef Server, and re-upload the one you want. This doesn't need any version number updates, and the end result is that Chef Server would have a single apache2 cookbook.

  2. Validate that your changes are indeed making it to Chef Server

    Using knife cookbook show apache2 <cookbook version> recipes default.rb Replace version, path, and filename - for instance if you wanted to view a template named foo.erb: knife cookbook show apache2 0.1.0 templates foo.erb

    This command will request the file from the Chef Server and display the output in your terminal. This is a simple way to determine that the changes you made are being uploaded via knife cookbook upload.

Beyond these, if this doesn't help out, adding the details of knife version, chef-server version, chef-client version as well as a debug log from knife cookbook upload apache2 -VV would be helpful in debugging further.

Solution 2:

First debug all version of cookbooks on server and then check which version of cookbook the client is downloading. if it is old, just check if the server has an updated version. if it is also yes, Please go to chef server UI and check for env. you might have setup an enviornment in which cookbooks constraint are specified. Please update the version over there and it will start working again.

Solution 3:

Another cause of this can be that not all the cookbook's dependencies are present on the chef-server. I ran into this just now, and the new version of my cookbook was showing up in knife cookbooks list but my client wasn't using the new version. After some debugging, I discovered that Berkshelf, nor knife had uploaded the new dependency for my cookbook. After I uploaded that, the client started using the newer version.