Tampa
Tampa

Reputation: 78412

Chef-solo and cookbook_path: multiple paths are not woking

Contrary to the docs...in my solo.rb file the below does not work:

 root = File.absolute_path(File.dirname(__FILE__))
 cookbook_path [ root + "/cookbooks",root + "/site-cookbooks", root + "/berks-cookbooks" ]

This works but defeats the purpose because I need to add the other two dirs in the cookbook paths:

root = File.absolute_path(File.dirname(__FILE__))
cookbook_path root + "/cookbooks"

Below is a sample role

{
    "name": "coordinator_do_server",
    "environment":{"git_repos":[]},
    "java":{ "install_flavor":"oracle","jdk_version":"7"},
    "run_list": ["recipe[build-essential]"
    ]
}

Error I get is the below:

Starting Chef Client, version 11.14.2

================================================================================
Error expanding the run_list:
================================================================================

Unexpected Error:
-----------------
TypeError: can't convert Array into String

[2014-12-07T18:22:07+08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 2.259210544 seconds
[2014-12-07T18:22:07+08:00] ERROR: can't convert Array into String
[2014-12-07T18:22:07+08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

How do I resolve?

Generated at 2014-12-08 00:12:42 +0800
TypeError: can't convert Array into String
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/environment.rb:248:in `directory?'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/environment.rb:248:in `load_from_file'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/environment.rb:241:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/node.rb:380:in `apply_expansion_attributes'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/node.rb:369:in `expand!'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/policy_builder/expand_node_object.rb:135:in `expand_run_list'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/policy_builder/expand_node_object.rb:122:in `build_node'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/client.rb:259:in `build_node'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/client.rb:420:in `do_run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/client.rb:213:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/client.rb:207:in `fork'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/client.rb:207:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/application.rb:237:in `run_chef_client'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/application/solo.rb:226:in `block in run_application'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/application/solo.rb:218:in `loop'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/application/solo.rb:218:in `run_application'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/lib/chef/application.rb:55:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.14.2/bin/chef-solo:25:in `<top (required)>'
/usr/local/bin/chef-solo:23:in `load'
/usr/local/bin/chef-solo:23:in `<main>'

Upvotes: 1

Views: 1094

Answers (1)

coderanger
coderanger

Reputation: 54267

The problem is that the chef_repo_path derives its default value from that of cookbook_path, and then the default environment_path is based on chef_repo_path. To fix this add chef_repo_path root to your config.

Upvotes: 1

Related Questions