Skip to content

Commit 69713f2

Browse files
committed
enable basic_users, nfs roles to be used directly
1 parent 3227599 commit 69713f2

File tree

6 files changed

+38
-61
lines changed

6 files changed

+38
-61
lines changed

ansible/roles/basic_users/tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
when:
6767
- item.state | default('present') == 'present'
6868
- item.create_home | default(true) | bool
69-
- inventory_hostname == basic_users_homedir_server
69+
- ansible_hostname == basic_users_homedir_server
7070

7171
# The following tasks run on a single *client* node, so that home directory
7272
# paths are easily constructed, becoming each user so that root-squash
@@ -85,7 +85,7 @@
8585
when:
8686
- item.state | default('present') == 'present'
8787
- item.generate_ssh_key | default(true) | bool or item.public_key is defined
88-
- inventory_hostname == basic_users_homedir_client
88+
- ansible_hostname == basic_users_homedir_client
8989

9090
- name: Generate cluster ssh key
9191
community.crypto.openssh_keypair:
@@ -101,7 +101,7 @@
101101
when:
102102
- item.state | default('present') == 'present'
103103
- item.generate_ssh_key | default(true)
104-
- inventory_hostname == basic_users_homedir_client
104+
- ansible_hostname == basic_users_homedir_client
105105
register: _cluster_ssh_keypair
106106

107107
- name: Write generated cluster ssh key to authorized_keys
@@ -118,7 +118,7 @@
118118
when:
119119
- item.item.state | default('present') == 'present'
120120
- item.item.generate_ssh_key | default(true)
121-
- inventory_hostname == basic_users_homedir_client
121+
- ansible_hostname == basic_users_homedir_client
122122
- item.public_key is defined # NB this is the *returned* public key
123123

124124
- name: Write supplied public key to authorized_keys
@@ -134,5 +134,5 @@
134134
label: "{{ item.name }}"
135135
when:
136136
- item.state | default('present') == 'present'
137-
- inventory_hostname == basic_users_homedir_client
137+
- ansible_hostname == basic_users_homedir_client
138138
- item.public_key is defined # NB this is the *provided* public key

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

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@
2929
tuned_enabled: true
3030
tuned_started: true
3131

32-
nfs_client_mnt_point: "/mnt"
33-
nfs_client_mnt_options: "defaults,nosuid,nodev"
34-
nfs_client_mnt_state: mounted
35-
nfs_configurations:
3632
nfs_enable:
3733
clients: false
3834

39-
# openhpc: no defaults required
40-
4135
os_manila_mount_shares: []
4236
os_manila_mount_ceph_conf_path: /etc/ceph
4337
os_manila_mount_state: mounted
@@ -50,13 +44,6 @@
5044
- nodev
5145
- nosuid
5246

53-
basic_users_userdefaults:
54-
state: present
55-
generate_ssh_key: true
56-
ssh_key_comment: "{{ item.name }}"
57-
basic_users_users: []
58-
basic_users_groups: []
59-
6047
tasks:
6148
- block:
6249
- name: Report skipping initialization if not compute node
@@ -110,11 +97,11 @@
11097
- meta: end_play
11198
when: not hostvars_stat.stat.exists
11299

113-
- name: Sync /mnt/cluster to /tmp
100+
- name: Sync /mnt/cluster to /var/tmp
114101
become_user: slurm
115102
synchronize:
116103
src: "/mnt/cluster/"
117-
dest: "/tmp/cluster/"
104+
dest: "/var/tmp/cluster/"
118105
archive: yes
119106
recursive: yes
120107

@@ -126,7 +113,7 @@
126113
- name: Load hostvars
127114
# this is higher priority than vars block = normal ansible's hostvars
128115
include_vars:
129-
file: "/tmp/cluster/hostvars/{{ ansible_hostname }}/hostvars.yml"
116+
file: "/var/tmp/cluster/hostvars/{{ ansible_hostname }}/hostvars.yml"
130117

131118
- name: Run chrony role
132119
ansible.builtin.include_role:
@@ -166,7 +153,7 @@
166153

167154
- name: Copy cluster /etc/hosts
168155
copy:
169-
src: /tmp/cluster/hosts
156+
src: /var/tmp/cluster/hosts
170157
dest: /etc/hosts
171158
owner: root
172159
group: root
@@ -177,14 +164,14 @@
177164
ansible.builtin.include_role:
178165
name: cacerts
179166
vars:
180-
cacerts_cert_dir: "/tmp/cluster/cacerts"
167+
cacerts_cert_dir: "/var/tmp/cluster/cacerts"
181168
when: enable_cacerts
182169

183170
- name: Configure sshd
184171
ansible.builtin.include_role:
185172
name: sshd
186173
vars:
187-
sshd_conf_src: "/tmp/cluster/hostconfig/{{ ansible_hostname }}/sshd.conf"
174+
sshd_conf_src: "/var/tmp/cluster/hostconfig/{{ ansible_hostname }}/sshd.conf"
188175
when: enable_sshd
189176

190177
- name: Configure tuned
@@ -196,22 +183,24 @@
196183
name: sssd
197184
tasks_from: configure.yml
198185
vars:
199-
sssd_conf_src: "/tmp/cluster/hostconfig/{{ ansible_hostname }}/sssd.conf"
186+
sssd_conf_src: "/var/tmp/cluster/hostconfig/{{ ansible_hostname }}/sssd.conf"
200187
when: enable_sssd
201188

202189
# NFS client mount
203190
- name: If nfs-clients is present
204-
include_tasks: tasks/nfs-clients.yml
191+
ansible.builtin.include_role:
192+
name: stackhpc.nfs
193+
tasks_from: nfs-clients.yml
205194
when:
206195
- enable_nfs
207-
- nfs_enable.clients | bool or ('nfs_enable' in item and item.nfs_enable.clients | bool)
196+
- nfs_enable.clients | default(item.nfs_enable.clients) | bool
208197
loop: "{{ nfs_configurations }}"
209198

210199
- name: Manila mounts
211200
block:
212201
- name: Read manila share info from nfs file
213202
include_vars:
214-
file: /tmp/cluster/manila_share_info.yml
203+
file: /var/tmp/cluster/manila_share_info.yml
215204
no_log: true # contains secrets
216205

217206
- name: Ensure Ceph configuration directory exists
@@ -286,39 +275,15 @@
286275
when: enable_lustre
287276

288277
- name: Basic users
289-
block:
290-
- name: Create groups
291-
ansible.builtin.group: "{{ item }}"
292-
loop: "{{ basic_users_groups }}"
293-
294-
- name: Create users
295-
user: "{{ basic_users_userdefaults | combine(item) | filter_user_params() | combine(_disable_homedir) }}"
296-
loop: "{{ basic_users_users }}"
297-
loop_control:
298-
label: "{{ item.name }}"
299-
vars:
300-
_disable_homedir: # ensure this task doesn't touch $HOME
301-
create_home: false
302-
generate_ssh_key: false
303-
304-
- name: Write sudo rules
305-
blockinfile:
306-
path: /etc/sudoers.d/80-{{ item.name }}-user
307-
block: "{{ item.sudo }}"
308-
create: true
309-
loop: "{{ basic_users_users }}"
310-
loop_control:
311-
label: "{{ item.name }}"
312-
when:
313-
- item.state | default('present') == 'present'
314-
- "'sudo' in item"
278+
ansible.builtin.include_role:
279+
name: basic_users
315280
when: enable_basic_users
316281

317282
- name: EESSI
318283
block:
319284
- name: Copy cvmfs config
320285
copy:
321-
src: /tmp/cluster/cvmfs/default.local
286+
src: /var/tmp/cluster/cvmfs/default.local
322287
dest: /etc/cvmfs/default.local
323288
owner: root
324289
group: root

ansible/roles/compute_init/tasks/export.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
dest: /exports/cluster/hosts
1515
owner: slurm
1616
group: root
17-
mode: u=rw,go=
17+
mode: u=r,g=rw,o=
1818
remote_src: true
1919
run_once: true
2020
delegate_to: "{{ groups['control'] | first }}"
@@ -43,7 +43,7 @@
4343
dest: /exports/cluster/manila_share_info.yml
4444
owner: slurm
4545
group: root
46-
mode: u=rw,g=r
46+
mode: u=r,g=rw,o=
4747
run_once: true
4848
delegate_to: "{{ groups['control'] | first }}"
4949
when: os_manila_mount_share_info is defined

ansible/roles/compute_init/tasks/install.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
dest: templates/ceph.keyring.j2
3434
- src: ../../resolv_conf/files/NetworkManager-dns-none.conf
3535
dest: files/NetworkManager-dns-none.conf
36-
- src: ../../basic_users/filter_plugins/filter_keys.py
37-
dest: filter_plugins/filter_keys.py
36+
- src: ../../basic_users
37+
dest: roles/
3838
- src: ../../cacerts
3939
dest: roles/
4040
- src: ../../sssd
@@ -43,8 +43,8 @@
4343
dest: roles/
4444
- src: ../../tuned/tasks/configure.yml
4545
dest: tasks/tuned.yml
46-
- src: ../../stackhpc.nfs/tasks/nfs-clients.yml
47-
dest: tasks/nfs-clients.yml
46+
- src: ../../stackhpc.nfs
47+
dest: roles/
4848
- src: ../../mrlesmithjr.chrony
4949
dest: roles/
5050
- src: ../../lustre

environments/common/inventory/group_vars/all/basic_users.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
# See ansible/roles/basic_users/README.md for variable definitions.
44

55
basic_users_users: []
6+
7+
# The following are defined for the purpose of compute-init
8+
basic_users_homedir_server: "{{ groups['control'] | first }}"
9+
basic_users_homedir_client: "{{ groups['login'] | first }}"

environments/common/inventory/group_vars/all/nfs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ nfs_configurations:
2424
# NB: this is stackhpc.nfs role defaults but are set here to prevent being
2525
# accidently overriden via default options
2626
nfs_export_options: 'rw,secure,root_squash'
27+
# prevent non-cluster IPs mounting the share:
28+
# NB: this is set as default for all shares above but is repeated here
29+
# in case nfs_export_clients is overriden
30+
nfs_export_clients: "{{ _nfs_node_ips }}"
2731

2832
- comment: Export /exports/cluster from Slurm control node
2933
nfs_enable:
3034
server: "{{ inventory_hostname in groups['control'] }}"
3135
clients: false
3236
nfs_export: "/exports/cluster"
37+
# prevent non-cluster IPs mounting the share:
38+
# NB: this is set as default for all shares above but is repeated here
39+
# in case nfs_export_clients is overriden
40+
nfs_export_clients: "{{ _nfs_node_ips }}"

0 commit comments

Comments
 (0)