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

user::data_bag recipe doesn't read from the data bag variable #5

Closed
apsoto opened this issue Dec 2, 2011 · 2 comments
Closed

user::data_bag recipe doesn't read from the data bag variable #5

apsoto opened this issue Dec 2, 2011 · 2 comments

Comments

@apsoto
Copy link

apsoto commented Dec 2, 2011

The data_bag recipe incorrectly reads from the node['users'] attribute, but the data bag contents are in the users array

diff --git a/cookbooks/user/recipes/data_bag.rb b/cookbooks/user/recipes/data_bag.rb
index a2dab5f..87877f5 100644
--- a/cookbooks/user/recipes/data_bag.rb
+++ b/cookbooks/user/recipes/data_bag.rb
@@ -25,7 +25,7 @@ rescue => ex
   []
 end

-Array(node['users']).each do |i|
+users.each do |i|
   u = data_bag_item(bag, i)
   username = u['username'] || u['id']
@fnichol
Copy link
Owner

fnichol commented Jan 21, 2012

This recipe works through array (node['users']) so that if the users data bag had users:

[
  { 'id' => 'one' },
  { 'id' => 'two' },
  { 'id' => 'three' }
]

and I only wanted user "two" on one particular node, I could set node['users'] = ['two'] which would exclude users "one" and "three". Otherwise all nodes always get all users in the data bag.

However after looking at the code, that could have been made clearer. Worse yet that users variable didn't get used anywhere. Does the above commit help clarify this? Thank you!

@jaylevitt
Copy link

Otherwise all nodes always get all users in the data bag.

That's no longer true, correct? My node didn't get any users until I set node['users'].

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

3 participants