Files
Ansible-Bootstrap/tests/inputs/test_inputs.yml
T

36 lines
1.2 KiB
YAML

---
# Run: ansible-playbook tests/inputs/test_inputs.yml
- name: Strict input validator fixture tests
hosts: localhost
gather_facts: false
connection: local
vars_files:
- inputs_fixtures.yml
tasks:
- name: Run each input fixture
ansible.builtin.include_tasks: _assert_inputs.yml
loop: "{{ inputs_fixtures }}"
loop_control:
loop_var: inf
label: "{{ inf.name }}"
- name: Validate a host var holding values that cannot be decrypted
block:
- name: Run the validator on the vaulted host var
validate_inputs:
specs:
- "{{ playbook_dir }}/fixture_spec.yml"
register: inputs_vault_result
rescue:
- name: Keep the failed vault result
ansible.builtin.set_fact:
inputs_vault_result: "{{ ansible_failed_result }}"
- name: Assert a vaulted string passes and a vaulted non-list is reported
ansible.builtin.assert:
that:
- >-
inputs_vault_result.errors | default([]) == ['fixture.servers: expected list, got str']
fail_msg: "[inputs vault] got {{ inputs_vault_result.errors | default([]) }}"
success_msg: "[inputs vault] OK"