Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create windows user with chef and add user to the local Administrators group

Chef documentation for the user resource: http://docs.getchef.com/resource_user.html

Doing this works:

user "TestUser" do
  password "p@ssw0rd"
end

But when I add a gid it fails:

user "TestUser" do
  password "p@ssw0rd"
  gid "Administrators"
end

I've also tried passing .\Administrator, but get the same result:

[2014-08-08T14:00:11-07:00] FATAL: ArgumentError: user[TestUser] (test::users line 11) had an error: ArgumentError: The user does not belong to this group.

Is the purpose of gid not to specify group membership?

like image 780
Mike Robinet Avatar asked Aug 08 '14 21:08

Mike Robinet


1 Answers

Eventually figured it out. The trick is to modify the group like so:

user "TestUser" do
  password "p@ssw0rd"
end

group "Administrators" do
  action :modify
  members "TestUser"
  append true
end
like image 73
Mike Robinet Avatar answered Sep 24 '22 14:09

Mike Robinet