Skip to content

Commit 8689e91

Browse files
authored
Merge pull request #3744 from pullan1/pub/k8s_telemetry
Validation of the software_config JSON file in the local repo during load
2 parents cd75f46 + 7d84fb2 commit 8689e91

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

discovery/roles/configure_ochami/templates/cloud_init/ci-group-slurm_node_x86_64.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,4 @@
334334
- echo " Starting LDMS setup " | tee -a /var/log/ldms-cloudinit.log
335335

336336
- /root/ldms_sampler.sh
337-
{% endif %}
337+
{% endif %}

examples/software_config_template/template_rhel_10.0_multi_arch_software_config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"repo_config": "always",
55
"softwares": [
66
{"name": "default_packages", "arch": ["x86_64","aarch64"]},
7-
{"name": "cuda", "version": "13.0.1", "arch": ["x86_64","aarch64"]},
87
{"name": "openldap", "arch": ["x86_64","aarch64"]},
98
{"name": "nfs", "arch": ["x86_64","aarch64"]},
109
{"name": "slurm_custom", "arch": ["x86_64","aarch64"]},

local_repo/local_repo.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,30 @@
4545
- name: Set_fact for fetch cluster os version
4646
hosts: localhost
4747
connection: local
48+
gather_facts: false
49+
vars:
50+
input_file: "{{ hostvars['localhost']['input_project_dir'] }}/software_config.json"
4851
tasks:
52+
- name: Validate JSON before loading
53+
ansible.builtin.command: "jq . {{ input_file }}"
54+
register: json_check
55+
changed_when: false
56+
failed_when: false
57+
ignore_errors: true
58+
no_log: true
59+
60+
- name: Fail if JSON is invalid
61+
ansible.builtin.fail:
62+
msg: |
63+
JSON validation failed for software_config.json.
64+
File: {{ input_file }}
65+
{{ json_check.stderr | default('Unknown jq error') }}
66+
Please fix the JSON syntax
67+
when: json_check.rc != 0
68+
4969
- name: Load software_config JSON
5070
ansible.builtin.set_fact:
51-
software_config: "{{ lookup('file', hostvars['localhost']['input_project_dir'] ~ '/software_config.json') | from_json }}"
71+
software_config: "{{ lookup('file', input_file) | from_json }}"
5272

5373
- name: Set cluster OS version
5474
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)