I'm struggling on the deployment of a cookbook in chef. It's not finding files that are, however, present in the directory it's looking for.

My recipe installs and launch Apache, and then is supposed to replace the default index.html by a simple template i've generated, but it can't find my modified index.html.erb in the cookbook and so, don't replace it.

Here is my environment:

Printing version, that may be usefull:

[root@centos-bpo1 cookbooks]# chef --version
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

Printing the content of my cookbook "httpd_deploy":

[root@centos-bpo1 cookbooks]# cd httpd_deploy/
[root@centos-bpo1 httpd_deploy]# tree
├── Berksfile
├── chefignore
├── httpd_deploy
│   └── templates
│       └── index.html.erb
├── metadata.rb
├── README.md
├── recipes
│   └── default.rb
├── spec
│   ├── spec_helper.rb
│   └── unit
│       └── recipes
│           └── default_spec.rb
└── test
    └── smoke
        └── default
            └── default_test.rb

Printing the content of the recipe "httpd_deploy":

[root@centos-bpo1 httpd_deploy]# cat recipes/default.rb
# Cookbook:: httpd_deploy
# Recipe:: default
# Copyright:: 2017, The Authors, All Rights Reserved.
package 'httpd'
service 'httpd' do
action [:enable, :start]
template '/var/www/html/index.html' do
source 'index.html.erb'

Printing the content of the source file "index.html.erb":

[root@centos-bpo1 httpd_deploy]# cat httpd_deploy/templates/index.html.erb
Welcome to Chef Apache Deployment 

I'm launching the cookbook as a local test with:

[root@centos-bpo1 httpd_deploy]# cd ..
[root@centos-bpo1 cookbooks]# chef-client --local-mode --runlist 'recipe[httpd_deploy]'

Here are the results (truncated):

[2017-10-02T10:58:22+02:00] ERROR: template[/var/www/html/index.html] (httpd_deploy::default line 10) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd_deploy' (0.1.0) does not contain a file at any of these locations:

As the error message says, you need to place your template in templates/index.html.erb not httpd_deploy/templates/index.html.erb

|improve this answer|||||
  • Yes, that was it... I was following a bad tutorial. Thank you ! – barthelemypousset Oct 2 '17 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.