Skip to content

Commit 14e7dc6

Browse files
committed
support basic_users in compute-init
1 parent 68bec3e commit 14e7dc6

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

ansible/roles/compute_init/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ The check in 4b. above is what prevents the compute-init script from trying
3131
to configure the node before the services on the control node are available
3232
(which requires running the site.yml playbook).
3333

34-
The following roles are currently fully functional:
34+
The following roles/groups are currently fully functional:
3535
- `resolv_conf`: all functionality
3636
- `etc_hosts`: all functionality
3737
- `nfs`: client functionality only
38-
- `stackhpc.openhpc`: all functionality
38+
- `manila`: all functionality
39+
- `openhpc`: all functionality
40+
- `basic_users`: all functionality, assumes home directory already exists on
41+
shared storage
3942

4043
# Development/debugging
4144

ansible/roles/compute_init/files/compute-init.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
enable_etc_hosts: "{{ os_metadata.meta.enable_etc_hosts | default(false) | bool }}"
1212
enable_nfs: "{{ os_metadata.meta.enable_nfs | default(false) | bool }}"
1313
enable_manila: "{{ os_metadata.meta.enable_manila | default(false) | bool }}"
14+
enable_basic_users: "{{ os_metadata.meta.enable_basic_users | default(false) | bool }}"
1415

1516
# TODO: "= role defaults" - could be moved to a vars_file: on play with similar precedence effects
1617
resolv_conf_nameservers: []
@@ -34,6 +35,15 @@
3435
- _netdev # prevents mount blocking early boot before networking available
3536
- rw
3637

38+
basic_users_groups: []
39+
basic_users_manage_homedir: false # homedir must already exist on shared filesystem
40+
basic_users_userdefaults:
41+
state: present
42+
create_home: "{{ basic_users_manage_homedir }}"
43+
generate_ssh_key: "{{ basic_users_manage_homedir }}"
44+
ssh_key_comment: "{{ item.name }}"
45+
basic_users_users: []
46+
3747
tasks:
3848
- block:
3949
- name: Report skipping initialization if not compute node
@@ -194,7 +204,29 @@
194204
- enable_manila
195205
- os_manila_mount_shares | length > 0
196206

197-
# TODO: - name: Basic users setup
207+
- name: Basic users
208+
block:
209+
- name: Create groups
210+
ansible.builtin.group: "{{ item }}"
211+
loop: "{{ basic_users_groups }}"
212+
213+
- name: Create users
214+
user: "{{ basic_users_userdefaults | combine(item) | filter_user_params() }}"
215+
loop: "{{ basic_users_users }}"
216+
loop_control:
217+
label: "{{ item.name }} [{{ item.state | default('present') }}]"
218+
register: basic_users_info
219+
220+
- name: Write sudo rules
221+
blockinfile:
222+
path: /etc/sudoers.d/80-{{ item.name}}-user
223+
block: "{{ item.sudo }}"
224+
create: true
225+
loop: "{{ basic_users_users }}"
226+
loop_control:
227+
label: "{{ item.name }}"
228+
when: "'sudo' in item"
229+
when: enable_basic_users
198230

199231
# TODO: - name: Configure EESSI
200232

ansible/roles/compute_init/tasks/install.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
dest: templates/ceph.keyring.j2
3131
- src: ../../resolv_conf/files/NetworkManager-dns-none.conf
3232
dest: files/NetworkManager-dns-none.conf
33-
# - src: ../../basic_users/filter_plugins/filter_keys.py
34-
# dest: filter_plugins/filter_keys.py
33+
- src: ../../basic_users/filter_plugins/filter_keys.py
34+
dest: filter_plugins/filter_keys.py
3535
- src: ../../stackhpc.nfs/tasks/nfs-clients.yml
3636
dest: tasks/nfs-clients.yml
3737

0 commit comments

Comments
 (0)