community.general.merge_variables (8.5.0) — lookup

merge variables with a certain suffix

| "added in version" 6.5.0 of community.general"

Authors: Roy Lenferink (@rlenferink), Mark Ettema (@m-a-r-k-e), Alexander Petrenz (@alpex8)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

This lookup returns the merged result of all variables in scope that match the given prefixes, suffixes, or regular expressions, optionally.

Inputs

    
_terms:
    description:
    - Depending on the value of O(pattern_type), this is a list of prefixes, suffixes,
      or regular expressions that will be used to match all variables that should be merged.
    elements: str
    required: true
    type: list

groups:
    description:
    - Search for variables accross hosts that belong to the given groups. This allows
      to collect configuration pieces accross different hosts (for example a service on
      a host with its database on another host).
    elements: str
    type: list
    version_added: 8.5.0
    version_added_collection: community.general

override:
    choices:
    - error
    - warn
    - ignore
    default: error
    description:
    - Return an error, print a warning or ignore it when a key will be overwritten.
    - The default behavior V(error) makes the plugin fail when a key would be overwritten.
    - When V(warn) and V(ignore) are used, note that it is important to know that the
      variables are sorted by name before being merged. Keys for later variables in this
      order will overwrite keys of the same name for variables earlier in this order.
      To avoid potential confusion, better use O(override=error) whenever possible.
    env:
    - name: ANSIBLE_MERGE_VARIABLES_OVERRIDE
    ini:
    - key: override
      section: merge_variables_lookup
    type: str

pattern_type:
    choices:
    - prefix
    - suffix
    - regex
    default: regex
    description:
    - Change the way of searching for the specified pattern.
    env:
    - name: ANSIBLE_MERGE_VARIABLES_PATTERN_TYPE
    ini:
    - key: pattern_type
      section: merge_variables_lookup
    type: str

initial_value:
    description:
    - An initial value to start with.
    type: raw

Outputs

_raw:
  description: In case the search matches list items, a list will be returned. In
    case the search matches dicts, a dict will be returned.
  elements: raw
  type: raw