ansible.utils/tests/integration/targets/utils_index_of/tasks/argspec.yaml

64 lines
1.5 KiB
YAML

---
- name: Set fact
ansible.builtin.set_fact:
complex:
a:
b:
c:
d:
- e0: 0
e1: ansible
e2: true
- e0: 1
e1: redhat
- name: Check argspec validation with filter (not a list)
ansible.builtin.set_fact:
_result: "{{ complex | ansible.utils.index_of('eq', 2) }}"
ignore_errors: true
register: result
- name: Assert
ansible.builtin.assert:
that: "{{ msg in result.msg }}"
vars:
msg: "cannot be converted to a list"
- name: Check argspec validation with filter (missing params)
ansible.builtin.set_fact:
_result: "{{ complex.a.b.c.d | ansible.utils.index_of() }}"
ignore_errors: true
register: result
- name: Assert
ansible.builtin.assert:
that: "{{ msg in result.msg }}"
vars:
msg: "missing required arguments: test"
- name: Check argspec validation with lookup (not a list)
ansible.builtin.set_fact:
_result: "{{ lookup('ansible.utils.index_of', complex, 'eq', 2) }}"
ignore_errors: true
register: result
- name: Assert
ansible.builtin.assert:
that: "{{ msg in result.msg }}"
vars:
msg: "cannot be converted to a list"
- name: Check argspec validation with lookup (missing params)
ansible.builtin.set_fact:
_result: "{{ lookup('ansible.utils.index_of') }}"
ignore_errors: true
register: result
- name: Assert
ansible.builtin.assert:
that: "{{ item in result.msg }}"
loop:
- "missing required arguments:"
- data
- test