I am executing the chef cookbook recipe in local mode, I have placed the template .erb file under cookbooks templates folder. It giving error and Chef::Exceptions::CookbookNotFound
attaching execution log
PS C:\chef-repo> chef-client -z -r "recipe[my_cookbook::test1]"
Starting Chef Client, version 12.18.31
resolving cookbooks for run list: ["my_cookbook::test1"]
Synchronizing Cookbooks:
- test (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 1 resources
Recipe: test::test1
* template[c:\test-template.txt] action create
================================================================================
Error executing action `create` on resource 'template[c:\test-template.txt]'
================================================================================
Chef::Exceptions::CookbookNotFound
----------------------------------
Cookbook test not found. If you're loading test from another cookbook, make sure you configure the dependency in you
r metadata
Resource Declaration:
---------------------
# In c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/recipes/test1.rb
1: template "c:\\test-template.txt" do
2: source "test-template.txt.erb"
3: mode '0755'
4: variables({
5: test: node['cloud']['public_ipv4']
6: })
7: end
Compiled Resource:
------------------
# Declared in c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/recipes/test1.rb:1:in `from_file'
template("c:\test-template.txt") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source "test-template.txt.erb"
variables {:test=>"1.1.1.1"}
declared_type :template
cookbook_name "test"
recipe_name "test1"
mode "0755"
path "c:\\test-template.txt"
end
Platform:
---------
x64-mingw32
Running handlers:
[2017-03-08T12:32:35+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-03-08T12:32:35+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 05 seconds
[2017-03-08T12:32:35+00:00] FATAL: Stacktrace dumped to c:/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out
[2017-03-08T12:32:35+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-03-08T12:32:35+00:00] FATAL: Chef::Exceptions::CookbookNotFound: template[c:\test-template.txt] (test::test1 line
1) had an error: Chef::Exceptions::CookbookNotFound: Cookbook test not found. If you're loading test from another cookbo
ok, make sure you configure the dependency in your metadata
test1.rb
template "c:\\test-template.txt" do
source "test-template.txt.erb"
mode '0755'
variables({
test: node['cloud']['public_ipv4']
})
end
My chef-repo tree :
C:.
├───.chef
│ └───local-mode-cache
│ └───cache
│ └───cookbooks
│ └───test
│ ├───attributes
│ ├───recipes
│ └───templates
| |___test-template.txt.erb
├───cookbooks
│ └───my_cookbook
│ ├───attributes
│ ├───definitions
│ ├───files
│ │ └───default
│ ├───libraries
│ ├───providers
│ ├───recipes
│ ├───resources
│ └───templates
│ └───default
| |___test-template.txt.erb
├───data_bags
│ └───example
├───environments
├───nodes
└───roles
Just a guess but here's what I think is wrong:
The template resource looks for a source file in c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/test/templates/test-template.txt.erb
.
With those log line:
resolving cookbooks for run list: ["my_cookbook::test1"]
...
Converging 1 resources
Recipe: test::test1
This makes me think taht either:
Your actual cookbook template is at "c:/chef-repo/.chef/local-mode-cache/cache/cookbooks/my_cookbook/templates/test-template.txt.erb" and your metadata.rb use the wrong name
attribute.
You have a typo somewhere in the template name or location while playing with a wrapper cookbook.