ansible / ansible.builtin / v2.16.0 / lookup / inventory_hostnames list of inventory hosts matching a host pattern | "added in version" 1.3 of ansible.builtin" Authors: Michael DeHaan, Steven Dossett (!UNKNOWN) <sdossett@panath.com>ansible.builtin.inventory_hostnames (v2.16.0) — lookup
pip
Install with pip install ansible-core==2.16.0
This lookup understands 'host patterns' as used by the C(hosts:) keyword in plays and can return a list of matching hosts from inventory
- 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
_hostnames: description: list of hostnames that matched the host pattern in inventory type: list