Search code examples
chef-infrachef-recipe

Error while using CHEF "group" resource


Hi I am using the below code to create a group, i would like chef to use "Chef::Provider::Group::Groupadd" provider, i am executing this on Red Hat Enterprise Linux Server release 6.4.

chef client version 11.4.0

Chef recipie used to create the group

group node['was']['usr_grp'] do
   action :create
end

ERROR

================================================================================
Error executing action `create` on resource 'group[webspher]'
================================================================================


Chef::Exceptions::Exec
----------------------
groupmod webspher returned 6, expected 0


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/WAS/recipes/default.rb

 35: group node['was']['usr_grp'] do
 36:   action :create
 37: end
 38:



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/WAS/recipes/default.rb:35:in `from_file'

group("webspher") do
  action [:create]
  retries 0
  retry_delay 2
  group_name "webspher"
  gid 901
  cookbook_name "WAS"
  recipe_name "default"
end



[2013-09-25T13:36:45-05:00] INFO: Running queued delayed notifications before re-raising exception
[2013-09-25T13:36:45-05:00] ERROR: Running exception handlers
[2013-09-25T13:36:45-05:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2013-09-25T13:36:45-05:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-09-25T13:36:45-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-09-25T13:36:45-05:00] FATAL: Chef::Exceptions::Exec: group[webspher] (WAS::default line 35) had an error: Chef::Exceptions::Exec: groupmod webspher returned 6, expected 0

Solution

  • Thanks Kamararadclimber, as you also mentioned exit code 6 means group does not exist, so ideally it should create the group.

    The problem I found was local to our environment. We have active directory tied up with our systems so group and users are created in Active directory and mapped to the machines.

    Somehow the user I was trying to create was there in the active directory but was not mapped properly, i.e it was not present in /etc/groups.

    Chef somehow was able to find out that the group existed, not sure how it was actually figuring it out in the active directory, but it was and hence giving the error.

    groupadd worked fine becuase it just created the group locally and was not checking anywhere in active directory.

    Thanks for all the support