inventory_hostnames¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in version1.3.
Synopsis¶
- This lookup understands 'host patterns' as used by the C(hosts:) keyword in plays and can return a list of matching hosts from inventory
Notes¶
Note
- this is only worth for 'hostname patterns' it is easier to loop over the group/group_names variables otherwise.
Examples¶
- name: show all the hosts matching the pattern, i.e. all but the group www
ansible.builtin.debug:
msg: "{{ item }}"
with_inventory_hostnames:
- all:!www
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _hostnames | list | list of hostnames that matched the host pattern in inventory |
Authors¶
- Michael Dehaan
- Steven Dossett (!unknown) Sdossett@panath.com