Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using multiple cookbooks to set specific whitelist items #132

Open
hugo-cisneiros-movile opened this issue Jul 31, 2017 · 0 comments
Open

Comments

@hugo-cisneiros-movile
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant