diff --git a/ansible/validate.yml b/ansible/validate.yml index 33412756c..034f4698a 100644 --- a/ansible/validate.yml +++ b/ansible/validate.yml @@ -43,6 +43,37 @@ # below produced by dev/setup-env.sh - gives empty list if file is missing: _requirements_installed: "{{ ((lookup('file', _requirements_path + '.last', errors='ignore') or '{}') | from_yaml ).values() | flatten }}" +- name: Validate OpenTofu templated inventory is appropriate + # This "documents" the assumptions that Ansible makes about the + # OpenTofu-provided inventory + hosts: localhost + gather_facts: false + tags: + - validate + - opentofu + tasks: + - name: Check templated groups + assert: + that: + - item in groups + - groups[item] | length > 0 + fail_msg: > + Expected inventory group '{{ item }}' is missing or empty: + - Check OpenTofu inventory template is up to date + - Check OpenTofu configuration defines 'login' and 'compute' variables properly + loop: + - control + - compute + - login + - name: Check templated 'all' vars + assert: + that: + - openhpc_cluster_name is defined + - cluster_domain_suffix is defined + - cluster_home_volume is defined + - cluster_compute_groups is defined + fail_msg: "One or more expected variables are missing: is OpenTofu inventory template up to date?" + - name: Ensure control node is in inventory hosts: all gather_facts: false