Skip to content

Commit 4ef845b

Browse files
authored
add groups support to basic_users (#406)
1 parent cbfbb89 commit 4ef845b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

ansible/roles/basic_users/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ Requirements
1616
Role Variables
1717
--------------
1818

19-
`basic_users_users`: Required. A list of mappings defining information for each user. In general, mapping keys/values are passed through as parameters to [ansible.builtin.user](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html) and default values are as given there. However:
20-
- `create_home`, `generate_ssh_key` and `ssh_key_comment` are set automatically and should not be overriden.
21-
- `uid` should be set, so that the UID/GID is consistent across the cluster (which Slurm requires).
22-
- `shell` if *not* set will be `/sbin/nologin` on the `control` node and the default shell on other users. Explicitly setting this defines the shell for all nodes.
23-
- An additional key `public_key` may optionally be specified to define a key to log into the cluster.
24-
- An additional key `sudo` may optionally be specified giving a string (possibly multiline) defining sudo rules to be templated.
25-
- Any other keys may present for other purposes (i.e. not used by this role).
19+
- `basic_users_users`: Optional, default empty list. A list of mappings defining information for each user. In general, mapping keys/values are passed through as parameters to [ansible.builtin.user](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html) and default values are as given there. However:
20+
- `create_home`, `generate_ssh_key` and `ssh_key_comment` are set automatically; this assumes home directories are on a cluster-shared filesystem.
21+
- `uid` should be set, so that the UID/GID is consistent across the cluster (which Slurm requires).
22+
- `shell` if *not* set will be `/sbin/nologin` on the `control` node and the default shell on other users. Explicitly setting this defines the shell for all nodes.
23+
- An additional key `public_key` may optionally be specified to define a key to log into the cluster.
24+
- An additional key `sudo` may optionally be specified giving a string (possibly multiline) defining sudo rules to be templated.
25+
- Any other keys may present for other purposes (i.e. not used by this role).
26+
- `basic_users_groups`: Optional, default empty list. A list of mappings defining information for each group. Mapping keys/values are passed through as parameters to [ansible.builtin.group](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/group_module.html) and default values are as given there.
2627

2728
Dependencies
2829
------------

ansible/roles/basic_users/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ basic_users_userdefaults:
55
generate_ssh_key: "{{ basic_users_manage_homedir }}"
66
ssh_key_comment: "{{ item.name }}"
77
shell: "{{'/sbin/nologin' if 'control' in group_names else omit }}"
8+
basic_users_users: []
9+
basic_users_groups: []

ansible/roles/basic_users/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
when:
99
- "item.state | default('present') == 'absent'"
1010

11+
- name: Create groups
12+
ansible.builtin.group: "{{ item }}"
13+
loop: "{{ basic_users_groups }}"
14+
1115
- name: Create users and generate public keys
1216
user: "{{ basic_users_userdefaults | combine(item) | filter_user_params() }}"
1317
loop: "{{ basic_users_users }}"

0 commit comments

Comments
 (0)