sous-chefs / users

Development repository for the users cookbook
https://supermarket.chef.io/cookbooks/users
Apache License 2.0
138 stars 218 forks source link

Converge fails with group_id set in v5.2.0 #412

Closed cbreden closed 6 years ago

cbreden commented 6 years ago

Cookbook version

5.2.0 (working in 5.1.0)

Chef-client version

13.5.3

Platform Details

ubuntu 16.04

Scenario:

calling users_manager files with group id set

Steps to Reproduce:

users_manage "itops" do
  group_id 2300
  action [ :remove, :create ]
end

Expected Result:

A converged run

Actual Result:

           ================================================================================
           Error executing action `create` on resource 'users_manage[itops]'
           ================================================================================

           NoMethodError
           -------------
           undefined method `each' for #<String:0x000000000504a010>

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/users/resources/manage.rb:98:in `block (2 levels) in class_from_file'
           /tmp/kitchen/cache/cookbooks/users/resources/manage.rb:36:in `block in class_from_file'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/spireon_users/recipes/group_itops.rb

             6: users_manage "itops" do
             7:   group_id 2300
             8:   action [ :remove, :create ]
             9: end
            10:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/spireon_users/recipes/group_itops.rb:6:in `from_file'

           users_manage("itops") do
             action [:remove, :create]
             default_guard_interpreter :default
             declared_type :users_manage
             cookbook_name "spireon_users"
             recipe_name "group_itops"
             group_id 2300
             search_group "itops"
             group_name "itops"
           end

           System Info:
           ------------
           chef_version=13.5.3
           platform=ubuntu
           platform_version=16.04
           ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
           program_name=chef-client worker: ppid=173;start=18:54:22;
           executable=/opt/chef/bin/chef-client
chobbs- commented 6 years ago

I just got the same error but don't have the group_id set. Instead, I believe this is pointing towards the data bag contents for key "ssh-keys". Previously having only a single ssh-key, I just had a string there. And from the docs:

Note: The ssh_keys attribute below can be either a String or an Array. However, we are recommending the use of an Array.

I changed the ssh-keys in the data bag to an array and now chef runs are completing successfully.

From this: "ssh-keys": "ssh blaha",

To: "ssh-keys": [ "ssh blaha" ],

To team: Did you remove this functionality? Can you update your docs if so? Thanks!

tas50 commented 6 years ago

So technically they were always meant to be arrays, but I've put some defensive code in to make sure if you pass a string we convert it to an array first. Let me know if you still have problems with the new 5.2.1 release which includes that.

cbreden commented 6 years ago

5.2.1 is working, thank you!