stephrobert.scaleway.select_hosts filter – Resolve a selector into inventory host names

Note

This filter plugin is part of the stephrobert.scaleway collection (version 0.7.0).

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 stephrobert.scaleway.

To use it in a playbook, specify: stephrobert.scaleway.select_hosts.

Synopsis

  • Turns group, name or tags into the list of inventory hosts it designates, so every operation accepts the same way of saying what to act on.

  • Refuses an ambiguity rather than settling it, refuses an unknown key rather than selecting nothing, and compares names exactly.

Input

This describes the input of the filter, the value before | stephrobert.scaleway.select_hosts.

Parameter

Comments

Input

dictionary / required

The selector. Exactly one of group, name or tags, plus match when tags is used.

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 | stephrobert.scaleway.select_hosts(key1=value1, key2=value2, ...)

Parameter

Comments

groups

dictionary / required

Ansible’s own groups, passed through.

hostvars

dictionary / required

Ansible’s own hostvars, passed through.

Examples

- name: Every production machine, by tag
  ansible.builtin.set_fact:
    cibles: >-
      {{ {'tags': ['production', 'web']}
         | stephrobert.scaleway.select_hosts(groups=groups, hostvars=hostvars) }}

Return Value

Key

Description

Return value

list / elements=string

The inventory host names the selector designates, sorted.

Returned: success