|
| 1 | +# Users role |
| 2 | + |
| 3 | +Role to manage users on a system. |
| 4 | + |
| 5 | +## Role configuration |
| 6 | + |
| 7 | +* users_create_per_user_group (default: true) - when creating users, also |
| 8 | + create a group with the same username and make that the user's primary |
| 9 | + group. |
| 10 | +* users_group (default: users) - if users_create_per_user_group is _not_ set, |
| 11 | + then this is the primary group for all created users. |
| 12 | +* users_default_shell (default: /bin/bash) - the default shell if none is |
| 13 | + specified for the user. |
| 14 | +* users_create_homedirs (default: true) - create home directories for new |
| 15 | + users. Set this to false is you manage home directories separately. |
| 16 | + |
| 17 | +## Creating users |
| 18 | + |
| 19 | +Add a users variable containing the list of users to add. A good place to put |
| 20 | +this is in `group_vars/all` or `group_vars/groupname` if you only want the |
| 21 | +users to be on certain machines. |
| 22 | + |
| 23 | +The following attributes are required for each user: |
| 24 | + |
| 25 | +* username - The user's username. |
| 26 | +* name - The full name of the user (gecos field) |
| 27 | +* uid - The numeric user id for the user. This is required for uid consistency |
| 28 | + across systems. |
| 29 | +* groups - a list of supplementary groups for the user. |
| 30 | +* ssh-key - This should be a list of ssh keys for the user. Each ssh key |
| 31 | + should be included directly and should have no newlines. |
| 32 | + |
| 33 | +In addition, the following items are optional for each user: |
| 34 | + |
| 35 | +* shell - The user's shell. This defaults to /bin/bash. The default is |
| 36 | + configurable using the users_default_shell variable if you want to give all |
| 37 | + users the same shell, but it is different than /bin/bash. |
| 38 | + |
| 39 | +Example: |
| 40 | + |
| 41 | + --- |
| 42 | + users: |
| 43 | + - username: foo |
| 44 | + name: Foo Barrington |
| 45 | + groups: ['wheel','systemd-journal'] |
| 46 | + uid: 1001 |
| 47 | + ssh_key: |
| 48 | + - "ssh-rsa AAAAA.... foo@machine" |
| 49 | + - "ssh-rsa AAAAB.... foo2@machine" |
| 50 | + users_deleted: |
| 51 | + - username: bar |
| 52 | + name: Bar User |
| 53 | + uid: 1002 |
| 54 | + |
| 55 | +## Deleting users |
| 56 | + |
| 57 | +The `users_deleted` variable contains a list of users who should no longer be |
| 58 | +in the system, and these will be removed on the next ansible run. The format |
| 59 | +is the same as for users to add, but the only required field is `username`. |
| 60 | +However, it is recommended that you also keep the `uid` field for reference so |
| 61 | +that numeric user ids are not accidentally reused. |
0 commit comments