Basic user management in Chef is achieved through the use of the user
resource. This resource allows you to add, remove, or otherwise manipulate users on your hosts. However, you can't possibly write recipes that contain one resource per user; it simply wouldn't scale. In order to make large-scale user management easier, we can combine some of Chef's capabilities such as data bags, per-role, per-node, and per-environment configuration to enable scalable user management.
Let's take a look at a user
cookbook that can provide these abilities.
First, let's take a look at a very naive user management recipe. This cookbook has a hardcoded users
list; initially, it contains frodo
and samwise
and simply iterates through the list, creating users as it goes. Here is what the list may look like:
users = [ { 'id' => 'frodo', 'uid' => '100', 'gid' => 100, 'shell' => '/bin/hobbitshell', 'comment' => 'Frodo of the nine...