chef-boneyard / push-jobs-cookbook

Development repository for Chef Cookbook push-jobs
https://supermarket.chef.io/cookbooks/push-jobs
Apache License 2.0
21 stars 43 forks source link

Using multiple cookbooks to set specific whitelist items #132

Open hugo-cisneiros-movile opened 7 years ago

hugo-cisneiros-movile commented 7 years ago

Cookbook version

5.1.2

Chef-client version

12.20.3

Platform Details

Running on AWS.

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

Scenario:

Se whitelist items in multiple wrapper cookbooks

Steps to Reproduce:

I'm trying to setup a "base" wrapper cookbook that implements common commands across all servers. For example:

And then, on a separate cookbook, include a custom command only for some servers that use the recipe. For example:

From my knowledge, both attributes are to be merged on the chef compile phase, then used to modify configuration on /etc/chef/push-jobs-client.rb.

But only the first entry, from the "base" cookbook, is working :(

I double-checked the attribute merging:

$ sudo chef-shell -z
chef (12.20.3)> require 'pp'
chef (12.20.3)> pp node.debug_value('push_jobs', 'whitelist')
[["default",
  {"chef-client"=>"chef-client",
   "uptime"=>"uptime",
   "tellah_deploy"=>"chef-client"}],
 ["env_default", :not_present],
 ["role_default", :not_present],
 ["force_default", :not_present],
 ["normal", :not_present],
 ["override", :not_present],
 ["role_override", :not_present],
 ["env_override", :not_present],
 ["force_override", :not_present],
 ["automatic", :not_present]]

It's there! But looks like the library helper isn't getting the merged attribute from all compile phases, just the one before the initial include_recipe.

I can use node.normal instead of node.default and it works (unfortunately after the second chef run only), but this isn't really optimal. I usually avoid using node.normal since it's usually not coded in recipes and can be a pain.

Expected Result:

Would be great to have the cookbook read the whitelist attribute from all merged attributes from the compile phase, regardless where it was called.