feat(validation): expand glob patterns in the spec list
This commit is contained in:
@@ -14,6 +14,41 @@
|
||||
loop_var: inf
|
||||
label: "{{ inf.name }}"
|
||||
|
||||
- name: Expand a spec pattern
|
||||
validate_inputs:
|
||||
specs:
|
||||
- "{{ playbook_dir }}/fixture_*.yml"
|
||||
vars:
|
||||
fixture:
|
||||
name: web01
|
||||
servers: [10.0.0.1]
|
||||
register: inputs_pattern_result
|
||||
|
||||
- name: Assert the pattern matched the fixture spec
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- inputs_pattern_result is succeeded
|
||||
success_msg: "[inputs pattern] OK"
|
||||
|
||||
- name: Refuse a pattern that matches nothing
|
||||
block:
|
||||
- name: Run the validator with a pattern that matches no file
|
||||
validate_inputs:
|
||||
specs:
|
||||
- "{{ playbook_dir }}/nothing_*.yml"
|
||||
register: inputs_nomatch_result
|
||||
rescue:
|
||||
- name: Keep the no-match failure
|
||||
ansible.builtin.set_fact:
|
||||
inputs_nomatch_result: "{{ ansible_failed_result }}"
|
||||
|
||||
- name: Assert the empty pattern was refused
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- inputs_nomatch_result.msg is search('no spec file matches')
|
||||
fail_msg: "[inputs no-match] got {{ inputs_nomatch_result.msg | default('') }}"
|
||||
success_msg: "[inputs no-match] OK"
|
||||
|
||||
- name: Refuse a variable declared by two specs
|
||||
block:
|
||||
- name: Run the validator with the fixture spec twice
|
||||
|
||||
Reference in New Issue
Block a user