ansible.builtin.inventory_hostnames (v2.16.5) — lookup

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>

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

This lookup understands 'host patterns' as used by the C(hosts:) keyword in plays and can return a list of matching hosts from inventory

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Outputs

_hostnames:
  description: list of hostnames that matched the host pattern in inventory
  type: list