Snigda
Snigda

Reputation: 11

Error Resolving Cookbooks for runlist: missing cookbooks: No such Cookbook 'docker'

I am trying to run this

Berksfile:

source 'https://supermarket.chef.io'
metadata

metadata.rb:

name 'my_jenkins_cookbook'

depends 'git'
depends 'ruby_rbenv'
depends 'jenkins'
depends 'java'
depends 'docker'

version '0.0.2'

I have also tried will the required cookbooks in local and it doesn't locate jenkins_job resource from the jenkins_job cookbook.

Can someone help me with this blockage please?

Image - is the error

TERMINAL OUTPUT:

 [DEBUG] Running command 4-run-chef-solo
 [DEBUG] No test for command 4-run-chef-solo
 [ERROR] Command 4-run-chef-solo (chef-solo -c /tmp/chef/solo.rb -j /tmp/chef/jenkins.json) failed
 [DEBUG] Command 4-run-chef-solo output: Starting Chef Infra Client, version 17.0.242
Patents: https://www.chef.io/patents
resolving cookbooks for run list: ["my_jenkins_cookbook::jenkins_jobs", "my_jenkins_cookbook::jenkins_views", "my_jenkins_cookbook::setup_jenkins_users"]

============================================================
Error Resolving Cookbooks for Run List:
============================================================

Missing Cookbooks:
------------------
No such cookbook: docker

Expanded Run List:
------------------
* my_jenkins_cookbook::jenkins_jobs
* my_jenkins_cookbook::jenkins_views
* my_jenkins_cookbook::setup_jenkins_users

System Info:
------------
chef_version=17.0.242
platform=ubuntu
platform_version=18.04
ruby=ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
program_name=/usr/bin/chef-solo
executable=/opt/chef/bin/chef-solo

Running handlers:
 ERROR: Running exception handlers
Running handlers complete
 ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 26 seconds
 FATAL: Stacktrace dumped to /tmp/chef/local-mode-cache/cache/chef-stacktrace.out
 FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
 FATAL: Net::HTTPServerException: 412 "Precondition Failed"

Upvotes: 1

Views: 1438

Answers (2)

Saravanan G
Saravanan G

Reputation: 581

Issue

Looks like the chef-solo execution could not find the dependent cookbooks, as indicated in the error log. So here is the alternative approach to solve the issue.

Resolution

Alternative suggestion for chef-solo is to run chef-client using -z option.

Chef client version 11 and above having an option called chef-client -z. It is called Chef client execution in local mode.

It is the suggested way to run cookbooks without Chef server.

Chef documentation for Chef-client states the below,

$ chef-client OPTION VALUE OPTION VALUE ...

-z, --local-mode
Run the chef-client in local mode. This allows all commands that work against the Chef server to also work against the local chef-repo.

Local mode does not require a configuration file, instead it will look for a directory named /cookbooks and will set chef_repo_path to be just above that. (Local mode will honor the settings in a configuration file, if desired.)

Local mode will store temporary and cache files under the <chef_repo_path>/.cache directory by default. This allows a normal user to run the chef-client in local mode without requiring root access.

So please follow the instructions below,

  • You need to create a project repository with your cookbooks and other stuff.
  • Project repo is nothing but a directory containing other directories for Roles, Databags, Cookbooks and Environments
  • Create a directory called cookbooks in the project repo
  • Since you already have the Berksfile in your cookbooks, run berks vendor cookbooks command from the each cookbook directory to pull all your dependent cookbooks and store it in the cookbooks directory
  • Run the below command from the project repo to invoke the Chef client in local mode.

chef-client -z -o 'provide_your_overridden_runlist'

  • This steps needs to be executed in the Jenkins script section

Read more in Chef Docs,

Upvotes: 0

Dan Webb
Dan Webb

Reputation: 64

how are you running this? Is this straight on a node with chef-client or through Test Kitchen?

It looks to me, like you're running chef-solo directly, but the cookbooks haven't been loaded onto the server.

Upvotes: 0

Related Questions