Skip to content

Commit e8e6d1c

Browse files
committed
Relax gres configuration validation to allow multiple conf keys
1 parent bfd3d67 commit e8e6d1c

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

tasks/validate.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,30 @@
2121
delegate_to: localhost
2222
run_once: true
2323

24-
- name: Check gres configuration when gres_autodetect is set
24+
- name: Check gres configuration
2525
assert:
2626
that:
27-
- _failure_reasons | selectattr('when', 'truthy') | length == 0
27+
- failure_reasons | length == 0
2828
fail_msg: >
29-
Your nodegroup definition must include a single gres dictionary containing a conf key
30-
if gres_autodetect is set. The following nodegroup failed this check: {{ item }}.
31-
Reasons for failure: {{ _failure_reasons | selectattr('when', 'truthy') | map(attribute='msg') | join(', ') }}
29+
Each list item in the gres dictionary of your nodegroup definition must
30+
contain a conf key. If gres_autodetect is not set, you must also include the
31+
file key. The following nodegroup failed this check: {{ item }}. Reasons for
32+
failure: {{ failure_reasons | map(attribute='msg') | join(', ') }}
3233
vars:
33-
_openhpc_gres_autodetect_groups: "{{ openhpc_nodegroups | selectattr('gres_autodetect', 'defined') | selectattr('gres_autodetect', 'search', '(?!off).*') }}"
34+
gres_autodetect: "{{ item.gres_autodetect | default('off') }}"
3435
_failure_reasons:
35-
- msg: The gres key was a list with more than one item
36-
when: "{{ item.gres | length != 1 }}"
37-
- msg: The gres dictionary does not contain a conf key
38-
when: "{{ item.gres.0.conf is not defined }}"
36+
- msg: One of the gres dictionaries does not contain a file key and gres_autodetect is off.
37+
condition: "{{ item.gres | rejectattr('file', 'defined') | length > 0 }}"
38+
when: "{{ gres_autodetect == 'off' }}"
39+
- msg: One of the gres dictionaries contains a file key and gres_autodetect is set.
40+
condition: "{{ item.gres | selectattr('file', 'defined') | length > 0 }}"
41+
when: "{{ gres_autodetect != 'off' }}"
42+
- msg: One of the gres dictionaries does not contain a conf key
43+
condition: "{{ item.gres | rejectattr('conf', 'defined') | length > 0 }}"
44+
when: true
45+
failure_reasons: "{{ _failure_reasons | selectattr('when', 'truthy') | selectattr('condition', 'truthy') }}"
3946
delegate_to: localhost
40-
loop: "{{ _openhpc_gres_autodetect_groups }}"
47+
loop: "{{ openhpc_nodegroups | selectattr('gres', 'defined') }}"
4148
run_once: true
4249

4350
- name: Fail if configuration is old

0 commit comments

Comments
 (0)