Skip to content

Commit 63118a4

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

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

tasks/validate.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,35 @@
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+
The gres key in your nodegroup definition must map to a list of
30+
dictionaries. The dictionaries should all contain a conf key. If
31+
gres_autodetect is not set, you must also include the file key. The
32+
following nodegroup failed this check: {{ item }}. Reasons for failure:
33+
{{ failure_reasons | map(attribute='msg') | join(', ') }}
3234
vars:
33-
_openhpc_gres_autodetect_groups: "{{ openhpc_nodegroups | selectattr('gres_autodetect', 'defined') | selectattr('gres_autodetect', 'search', '(?!off).*') }}"
35+
gres_autodetect: "{{ item.gres_autodetect | default('off') }}"
36+
gres_items: "{{ item.gres | select('mapping') }}"
3437
_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 }}"
38+
- msg: The gres key in your nodegroup defintion does not map to a list of dictionaries
39+
condition: "{{ item.gres is sequence and item.gres | reject('mapping') | length > 0 }}"
40+
when: true
41+
- msg: One of list items in the gres dictionary does not contain a file key and gres_autodetect is off
42+
condition: "{{ gres_items | rejectattr('file', 'defined') | length > 0 }}"
43+
when: "{{ gres_autodetect == 'off' }}"
44+
- msg: One of the list items in the gres dictionary contains a file key and gres_autodetect is set
45+
condition: "{{ gres_items | selectattr('file', 'defined') | length > 0 }}"
46+
when: "{{ gres_autodetect != 'off' }}"
47+
- msg: One of the list items in the gres dictionary does not contain a conf key
48+
condition: "{{ gres_items | rejectattr('conf', 'defined') | length > 0 }}"
49+
when: true
50+
failure_reasons: "{{ _failure_reasons | selectattr('when', 'truthy') | selectattr('condition', 'truthy') }}"
3951
delegate_to: localhost
40-
loop: "{{ _openhpc_gres_autodetect_groups }}"
52+
loop: "{{ openhpc_nodegroups | selectattr('gres', 'defined') }}"
4153
run_once: true
4254

4355
- name: Fail if configuration is old

0 commit comments

Comments
 (0)