sap.sap_operations.any filter – Return true if any element in the iterable is truthy.

Note

This filter plugin is part of the sap.sap_operations collection.

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install sap.sap_operations.

To use it in a playbook, specify: sap.sap_operations.any.

New in sap.sap_operations 1.7.0-galaxy

Synopsis

  • Return true if any element in the iterable is truthy.

  • If not iterable, return the truthyness of value provided.

  • Returns False if the iterable is empty (empty list, or empty string).

  • Behaves like the Python builtin any function (for Iterable)

  • If not Iterable provided, behaves like the Python builtin bool function (for value)

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | sap.sap_operations.any(key1=value1, key2=value2, ...)

Parameter

Comments

value

string / required

Iterable to check, if not iterable, return the truthyness of value provided.

Notes

Note

  • This module is community supported

  • Module interface (parameters, output) expected to be stable but not guaranteed

  • Module planned to be released on Ansible Automation Hub after collecting some feedback

  • There is no guarantee that this module will be officially supported by Red Hat

Examples

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ [true, true] | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ ['true', 'false'] | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ [1, 1] | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ not ([1, 0] | sap.sap_operations.any) }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ ['1', '0'] | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ 1 | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ not ( 0 | sap.sap_operations.any ) }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ '' | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ ' ' | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ {1: 2} | sap.sap_operations.any }}"

- name: Test 'any' filter, this assertion is True
  ansible.builtin.assert:
    that: "{{ not ( None | sap.sap_operations.any ) }}"

Return Value

Key

Description

data

boolean

True if any element in the iterable is truthy or value provided is truthy.

Returned: success

Sample: true

Authors

  • Kirill Satarin (@kksat)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.