push-jobs-cookbook
push-jobs-cookbook copied to clipboard
Using multiple cookbooks to set specific whitelist items
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:
- base/recipes/push-jobs.rb
node.default['push_jobs']['whitelist'].tap do |whitelist|
whitelist['chef-client'] = 'chef-client'
whitelist['uptime'] = 'uptime'
end
include_recipe 'push-jobs'
And then, on a separate cookbook, include a custom command only for some servers that use the recipe. For example:
- app/recipes/default.rb
node.default['push_jobs']['whitelist']['tellah_deploy'] = 'chef-client'
include_recipe 'base::chef-client'
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.