Skip to content

Commit f19fa33

Browse files
committed
Relax gres configuration validation to allow multiple list items
1 parent bfd3d67 commit f19fa33

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

tasks/validate.yml

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

24-
- name: Check gres configuration when gres_autodetect is set
24+
- name: Check Generic Resource (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') }}"
35+
gres_items: "{{ item.gres | select('mapping') }}"
3436
_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 }}"
37+
- msg: The gres key in your nodegroup defintion does not map to a list of dictionaries
38+
condition: "{{ item.gres is sequence and item.gres | reject('mapping') }}"
39+
when: true
40+
- msg: One of list items in the gres dictionary does not contain a file key and gres_autodetect is off
41+
condition: "{{ gres_items | rejectattr('file', 'defined') | length > 0 }}"
42+
when: "{{ gres_autodetect == 'off' }}"
43+
- msg: One of the list items in the gres dictionary contains a file key and gres_autodetect is set
44+
condition: "{{ gres_items | selectattr('file', 'defined') | length > 0 }}"
45+
when: "{{ gres_autodetect != 'off' }}"
46+
- msg: One of the list items in the gres dictionary does not contain a conf key
47+
condition: "{{ gres_items | rejectattr('conf', 'defined') | length > 0 }}"
48+
when: true
49+
failure_reasons: "{{ _failure_reasons | selectattr('when', 'truthy') | selectattr('condition', 'truthy') }}"
3950
delegate_to: localhost
40-
loop: "{{ _openhpc_gres_autodetect_groups }}"
51+
loop: "{{ openhpc_nodegroups | selectattr('gres', 'defined') }}"
4152
run_once: true
4253

4354
- name: Fail if configuration is old

0 commit comments

Comments
 (0)