4
votes

I'm trying to add a 'deploy' user to my web_app role using the 'generic-users' recipe with chef server. I've created a deploy.json databag containing:

{
  "id": "deploy",
  "group": "deploy",
  "shell": true
}

I've uploaded the data bag to my server.

I've also uploaded all my recipes and roles.

Finally, here's my app role:

name "app_server"
description "application"
run_list(
  "recipe[generic-users]",
)
default_attributes "users" => { "active_groups" => "deploy" }

When I try to provision my server using this role, I see the following:

[2012-09-24T22:17:53+01:00] INFO: Active groups: deploy, sysadmin

But it doesn't actually create my deploy user.

What do I need to do to get it to create my user?

Also, I'd like to specify different users and to be able to only create specific accounts on specific roles as necessary. How could I do that?

2

2 Answers

7
votes

Have you had a look into the User Resource and the Group Resource?

You can create groups and users in a declarative way:

group "magrathean" do
  gid 42
end

user "slartibartfast" do
  home "/home/slartibartfast"
  gid 42
  shell "/bin/bash"
  password "hashed password" 
end

Have a look at the section about hashed passwords.

We run a custom users cookbook which allows us to set up specific configuration files, like .alias, .bashrc, and alike.

0
votes

You may be thinking of the 'users' cookbook maintained by Chef (formerly Opscode), which does what you say. Given a data bag 'users' and the item 'deploy' (with the json as you declared it), it will create the user. It can also remove the user, or invoke any action from the 'user' resource as mentioned by Tilman. https://github.com/opscode-cookbooks/users