How to add all the groups to a newly created user?

Hi,

it is my user json file in the data bag

{

"id": "project",

"shell": "/bin/bash",

 "groups": ["vagrant", "wheel", "admin", "sensu", "chef", "adm", "cdrom",

“sudo”, “dip”, “plugdev”, “lpadamin”]

}

In my default.rb cookbook, I have these lines

include_recipe “users”

users_manage “admin” do

action [:create]

end

After the user is created, it looks like this:

$ id

uid=1000(project) gid=1000(project) groups=1000(project),2302(admin)

How can I get the user to be member of all the groups mentioned in the json
file?

Cheers,

Tony

The users_manage resource from the community "users" cookbook takes the
name of a group you want to configure and only ensures that group (and any
of its users) are on the system. If you want to ensure "vagrant", "wheel",
etc are on your system you must use a users_manage resource for all of the
groups you want configured on the system. Then you will see that your
"project" user is associated with the groups you expect.

A detailed look at how that works can be found on the Chef blog

On Tue, Feb 24, 2015 at 8:41 PM, Anthony Kong anthony.hw.kong@gmail.com
wrote:

Hi,

it is my user json file in the data bag

{

"id": "project",

"shell": "/bin/bash",

 "groups": ["vagrant", "wheel", "admin", "sensu", "chef", "adm",

"cdrom", "sudo", "dip", "plugdev", "lpadamin"]

}

In my default.rb cookbook, I have these lines

include_recipe "users"

users_manage "admin" do

action [:create]

end

After the user is created, it looks like this:

$ id

uid=1000(project) gid=1000(project) groups=1000(project),2302(admin)

How can I get the user to be member of all the groups mentioned in the
json file?

Cheers,

Tony

The ‘users’ cookbook basically requires a separate cookbook and recipes to manage your own group or list of groups. It would be potentially quite helpful to have that information selectable on a role or environment basis, rather than requiring in-house recipes.

Nico Kadel-Garcia
Lead DevOps Engineer
nkadel@skyhookwireless.commailto:nkadel@skyhookwireless.com

From: George Miranda [mailto:gmiranda@getchef.com]
Sent: Tuesday, February 24, 2015 11:53 PM
To: chef@lists.opscode.com
Subject: [chef] Re: How to add all the groups to a newly created user?

The users_manage resource from the community “users” cookbook takes the name of a group you want to configure and only ensures that group (and any of its users) are on the system. If you want to ensure “vagrant”, “wheel”, etc are on your system you must use a users_manage resource for all of the groups you want configured on the system. Then you will see that your “project” user is associated with the groups you expect.

A detailed look at how that works can be found on the Chef blog

On Tue, Feb 24, 2015 at 8:41 PM, Anthony Kong <anthony.hw.kong@gmail.commailto:anthony.hw.kong@gmail.com> wrote:
Hi,

it is my user json file in the data bag

{

"id": "project",

"shell": "/bin/bash",

 "groups": ["vagrant", "wheel", "admin", "sensu", "chef", "adm", "cdrom", "sudo", "dip", "plugdev", "lpadamin"]

}

In my default.rb cookbook, I have these lines

include_recipe “users”

users_manage “admin” do

action [:create]

end

After the user is created, it looks like this:

$ id

uid=1000(project) gid=1000(project) groups=1000(project),2302(admin)

How can I get the user to be member of all the groups mentioned in the json file?

Cheers,

Tony