Search code examples
chef-infrachef-soloberkshelf

Unable to find cookbook template when using Berkshelf


I'm using chef-solo and maintaining community cookbooks using berkshelf. Installed iptables cookbook using berkshelf recently and it threw the following error once I ran chef-solo.

RuntimeError
------------
File templates/default/rebuild-iptables.erb does not exist for cookbook iptables

Resource Declaration:
---------------------
# In /home/directfn/.berkshelf/cookbooks/iptables-2.0.1/recipes/default.rb

 35: template '/usr/sbin/rebuild-iptables' do
 36:   source 'rebuild-iptables.erb'
 37:   mode '0755'
 38:   variables(
 39:     hashbang: ::File.exist?('/usr/bin/ruby') ? '/usr/bin/ruby' : '/opt/chef/embedded/bin/ruby'
 40:   )
 41: end
 42: 

But I can see the template source is there.

[root@euca-172-16-10-197 chef-repo]# ls /home/directfn/.berkshelf/cookbooks/iptables-2.0.1/templates/default/rebuild-iptables.erb 
/home/directfn/.berkshelf/cookbooks/iptables-2.0.1/templates/default/rebuild-iptables.erb

But if I copy the iptables cookbook to where I have rest of my cookbooks are, it works like a charm. And I'm using more than 30 other community cookbooks using berkshelf without any problem.

Does anyone have an idea what is going on here?

Thanks in advance

solo.rb file

file_cache_path "/home/directfn/devops/chef-solo"
cookbook_path [
  "/home/directfn/devops/chef-repo/cookbooks",
  "/home/directfn/.berkshelf/cookbooks"
  ]
data_bag_path "/home/directfn/devops/chef-repo/data_bags"
environment "development"
environment_path "/home/directfn/devops/chef-repo/environments"

Json attributes file:

{
  "name": "phoenix_new",
  "description": "",
  "java": {
        "install_flavor": "oracle", 
        "jdk_version": 7,
        "oracle": {
                "accept_oracle_download_terms": true
        }
  },
  "phoenix": {
        "tag": "dbfs_release_0"
  },
  "run_list": [
                "recipe[phoenix::simple]"
  ],
  "env_run_lists": {

  }
}

Solution

  • chef-solo cannot use the cookbooks under .berkshelf/ directly. You should use berks vendor to reformat them into a structure that Chef can deal with better.