Jeetu
Jeetu

Reputation: 5

How to write a wrapper cookooks in chef for the local cookbooks and not dependent on the chef community chef cookbooks?

I have two base chef cookbooks which are written from scratch, one cookbook is dependent on the other. Both the cookbooks are not dependent on community cookbooks. So, I was asked to create a wrapper cookbook with the 2 base chef cookbooks

For example: I have two cookbooks "test-a" and "test-b" and both of them are available on the chef server hosted On-premises and are not dependent on the community cookbooks.

Ask is to create a wrapper cookbook "test" with the above cookbooks "test-a" and "test-b". so that, they can do a knife bootstrap/role/run_list.

Thanks in Advance

Upvotes: 0

Views: 318

Answers (1)

Mr.
Mr.

Reputation: 10122

utilize the run_list in the role object. in your case, it should be something like:

$ cat roles/test.json
{
  "run_list": [
    "recipe[test-a]",
    "recipe[test-b]"
  ]
}

another method, is to create another a cookbook named test and utilize the include_recipe, and it should be something like:

$ cat test/recipes/default.rb
include_recipe 'test-a'
include_recipe 'test-b'

$ cat test/metadata.rb
depends 'test-a'
depends 'test-b'

if you have attributes which you would like to override, then do it in the test wrapper cookbook. for instance, if the test-a cookbook has an attribute such as node.default[:foo] = 'baz', then you can override it as follows

$ cat test/attributes/default.rb
node.default[:foo] = 'spam'

consider reading Writing Wrapper Cookbooks and Doing Wrapper Cookbooks Right on chef blog

Upvotes: 0

Related Questions