<commit_before>users Cookbook
==============
Creates users from a databag search.


Requirements
------------
### Platforms
- Debian, Ubuntu
- CentOS, Red Hat, Fedora
- FreeBSD

A data bag populated with user objects must exist. The default data
bag in this recipe is `users`. See USAGE.


Usage
-----
To include just the LWRPs in your cookbook, use:

```ruby
include_recipe "users"
```

Otherwise, this cookbook is specific for setting up `sysadmin` group and users with the sysadmins recipe for now.

```ruby
include_recipe "users::sysadmins"
```

Use knife to create a data bag for users.

```bash
$ knife data bag create users
```

Create a user in the data_bag/users/ directory.

When using an [Omnibus ruby](http://tickets.opscode.com/browse/CHEF-2848), one can specify an optional password hash. This will be used as the user's password.

The hash can be generated with the following command.

```bash
$ openssl passwd -1 "<PASSWORD>"
```

Note: The ssh_keys attribute below can be either a String or an Array. However, we are recommending the use of an Array.

```javascript
{
  "id": "bofh",
  "ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh",
}
```

```javascript
{
  "id": "bofh",
  "password": <PASSWORD>",
  "ssh_keys": [
    "ssh-rsa AAA123...xyz== foo",
    "ssh-rsa AAA456...uvw== bar"
  ],
  "groups": [ "sysadmin", "dba", "devops" ],
  "uid": 2001,
  "shell": "\/bin\/bash",
  "comment": "BOFH",
  "nagios": {
    "pager": "<EMAIL>",
    "email": "<EMAIL>"
  },
  "openid": "bofh.myopenid.com"
}
```

You can pass any action listed in the [user](http://docs.opscode.com/chef/resources.html#id237) resource for Chef via the "action" option. For Example:

Lock a user, johndoe1.

```bash
$ knife data bag users johndoe1
```

And then change the action to "lock":

```javascript
{
  "id": "johndoe1",
  "groups": ["sysadmin", "dba", "devops"],
  "uid": 2002,
  "action": "lock", // <--
  "comment": "User violated access policy"
}
```

Remove a user, johndoe1.

```bash
$ knife data bag users johndoe1
```

And then change the action to "remove":

```javascript
{
  "id": "johndoe1",
  "groups": [ "sysadmin", "dba", "devops" ],
  "uid": 2002,
  "action": "remove", // <--
  "comment": "User quit, retired, or fired."
}
```

* Note only user bags with the "action : remove" and a search-able "group" attribute will be purged by the :remove action.

The sysadmins recipe makes use of the `users_manage` Lightweight Resource Provider (LWRP), and looks like this:

```ruby
users_manage "sysadmin" do
  group_id 2300
  action [ :remove, :create ]
end
```

Note this LWRP searches the `users` data bag for the `sysadmin` group attribute, and adds those users to a Unix security group `sysadmin`. The only required attribute is group_id, which represents the numeric Unix gid and *must* be unique. The default action for the LWRP is `:create` only.<commit_msg>Update README.md `knife data bag` commands<commit_after>users Cookbook
==============
Creates users from a databag search.


Requirements
------------
### Platforms
- Debian, Ubuntu
- CentOS, Red Hat, Fedora
- FreeBSD

A data bag populated with user objects must exist. The default data
bag in this recipe is `users`. See USAGE.


Usage
-----
To include just the LWRPs in your cookbook, use:

```ruby
include_recipe "users"
```

Otherwise, this cookbook is specific for setting up `sysadmin` group and users with the sysadmins recipe for now.

```ruby
include_recipe "users::sysadmins"
```

Use knife to create a data bag for users.

```bash
$ knife data bag create users
```

Create a user in the data_bag/users/ directory.

When using an [Omnibus ruby](http://tickets.opscode.com/browse/CHEF-2848), one can specify an optional password hash. This will be used as the user's password.

The hash can be generated with the following command.

```bash
$ openssl passwd -1 "plaintextpassword"
```

Note: The ssh_keys attribute below can be either a String or an Array. However, we are recommending the use of an Array.

```javascript
{
  "id": "bofh",
  "ssh_keys": "ssh-rsa AAAAB3Nz...yhCw== bofh",
}
```

```javascript
{
  "id": "bofh",
  "password": <PASSWORD>",
  "ssh_keys": [
    "ssh-rsa AAA123...xyz== foo",
    "ssh-rsa AAA456...uvw== bar"
  ],
  "groups": [ "sysadmin", "dba", "devops" ],
  "uid": 2001,
  "shell": "\/bin\/bash",
  "comment": "BOFH",
  "nagios": {
    "pager": "800555121<EMAIL>",
    "email": "<EMAIL>"
  },
  "openid": "bofh.myopenid.com"
}
```

You can pass any action listed in the [user](http://docs.opscode.com/chef/resources.html#id237) resource for Chef via the "action" option. For Example:

Lock a user, johndoe1.

```bash
$ knife data bag edit users johndoe1
```

And then change the action to "lock":

```javascript
{
  "id": "johndoe1",
  "groups": ["sysadmin", "dba", "devops"],
  "uid": 2002,
  "action": "lock", // <--
  "comment": "User violated access policy"
}
```

Remove a user, johndoe1.

```bash
$ knife data bag edit users johndoe1
```

And then change the action to "remove":

```javascript
{
  "id": "johndoe1",
  "groups": [ "sysadmin", "dba", "devops" ],
  "uid": 2002,
  "action": "remove", // <--
  "comment": "User quit, retired, or fired."
}
```

* Note only user bags with the "action : remove" and a search-able "group" attribute will be purged by the :remove action.

The sysadmins recipe makes use of the `users_manage` Lightweight Resource Provider (LWRP), and looks like this:

```ruby
users_manage "sysadmin" do
  group_id 2300
  action [ :remove, :create ]
end
```

Note this LWRP searches the `users` data bag for the `sysadmin` group attribute, and adds those users to a Unix security group `sysadmin`. The only required attribute is group_id, which represents the numeric Unix gid and *must* be unique. The default action for the LWRP is `:create` only.
{'fraction_non_alphanumeric': 0.1498703543647364, 'fraction_numerical': 0.014347450302506483, 'mean_word_length': 3.874473462510531, 'pattern_counts': {'":': 50, '<': 14, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '278236', 'n_tokens_mistral': 2122, 'n_tokens_neox': 1931, 'n_words': 734}