Mike Robinet
Mike Robinet

Reputation: 843

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?

Upvotes: 10

Views: 7232

Answers (1)

Mike Robinet
Mike Robinet

Reputation: 843

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

Upvotes: 17

Related Questions