Skip to content

Commit b0a9526

Browse files
committed
add validation for tofu-templated vars
1 parent bc0c66c commit b0a9526

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ansible/validate.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@
4343
# below produced by dev/setup-env.sh - gives empty list if file is missing:
4444
_requirements_installed: "{{ ((lookup('file', _requirements_path + '.last', errors='ignore') or '{}') | from_yaml ).values() | flatten }}"
4545

46+
- name: Validate OpenTofu templated inventory is appropriate
47+
# This "documents" the assumptions that Ansible makes about the
48+
# OpenTofu-provided inventory
49+
hosts: localhost
50+
gather_facts: false
51+
tags:
52+
- validate
53+
- opentofu
54+
tasks:
55+
- name: Check templated groups
56+
assert:
57+
that:
58+
- item in groups
59+
- groups[item] | length > 0
60+
fail_msg: "Expected inventory group '{{ item }}' is missing or empty: is OpenTofu inventory template up to date?"
61+
loop:
62+
- control
63+
- compute
64+
- login
65+
- name: Check templated 'all' vars
66+
assert:
67+
that:
68+
- openhpc_cluster_name is defined
69+
- cluster_domain_suffix is defined
70+
- cluster_home_volume is defined
71+
- cluster_compute_groups is defined
72+
fail_msg: "One or more expected variables are missing: is OpenTofu inventory template up to date?"
73+
4674
- name: Ensure control node is in inventory
4775
hosts: all
4876
gather_facts: false

0 commit comments

Comments
 (0)