Note
This module is part of ansible-base
and included in all Ansible installations. In most cases, you can use the short module name varnames even without specifying the collections:
keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.
New in version 2.8: of ansible.builtin
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
_terms string / required | List of Python regex patterns to search for in variable names. |
- name: List variables that start with qz_ debug: msg="{{ lookup('varnames', '^qz_.+')}}" vars: qz_1: hello qz_2: world qa_1: "I won't show" qz_: "I won't show either" - name: Show all variables debug: msg="{{ lookup('varnames', '.+')}}" - name: Show variables with 'hosts' in their names debug: msg="{{ lookup('varnames', 'hosts')}}" - name: Find several related variables that end specific way debug: msg="{{ lookup('varnames', '.+_zone$', '.+_location$') }}"
Common return values are documented here, the following are the fields unique to this lookup:
Key | Returned | Description |
---|---|---|
_value list / elements=string | success | List of the variable names requested. |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/builtin/varnames_lookup.html