Reputation: 11
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?
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
Reputation: 581
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.
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 setchef_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,
cookbooks
in the project repoBerksfile
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
directorychef-client -z -o 'provide_your_overridden_runlist'
Read more in Chef Docs,
Upvotes: 0
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