ansible.builtin.constructed (v2.16.5) — inventory

Uses Jinja2 to construct vars and groups based on existing inventory.

| "added in version" 2.4 of ansible.builtin"

Authors: unknown

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

Uses a YAML configuration file with a valid YAML or C(.config) extension to define var expressions and group conditionals

The Jinja2 conditionals that qualify a host for membership.

The Jinja2 expressions are calculated and assigned to the variables

Only variables already available from previous inventories or the fact cache can be used for templating.

When O(strict) is False, failed expressions will be ignored (assumes vars were missing).

Inputs

    
groups:
    default: {}
    description: Add hosts to group based on Jinja2 conditionals.
    type: dict

plugin:
    choices:
    - ansible.builtin.constructed
    - constructed
    description: token that ensures this is a source file for the 'constructed' plugin.
    required: true

strict:
    default: false
    description:
    - If V(yes) make invalid entries a fatal error, otherwise skip and continue.
    - Since it is possible to use facts in the expressions they might not always be available
      and we ignore those errors by default.
    type: bool

compose:
    default: {}
    description: Create vars from jinja2 expressions.
    type: dict

keyed_groups:
    default: []
    description: Add hosts to group based on the values of a variable.
    elements: dict
    suboptions:
      default_value:
        description:
        - The default value when the host variable's value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].trailing_separator).
        type: str
        version_added: '2.12'
        version_added_collection: ansible.builtin
      key:
        description:
        - The key from input dictionary used to generate groups
        type: str
      parent_group:
        description: parent group for keyed group
        type: str
      prefix:
        default: ''
        description: A keyed group name will start with this prefix
        type: str
      separator:
        default: _
        description: separator used to build the keyed group name
        type: str
      trailing_separator:
        default: true
        description:
        - Set this option to V(False) to omit the O(keyed_groups[].separator) after the
          host variable when the value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].default_value).
        type: bool
        version_added: '2.12'
        version_added_collection: ansible.builtin
    type: list

use_extra_vars:
    default: false
    description: Merge extra vars into the available variables for composition (highest
      precedence).
    env:
    - name: ANSIBLE_INVENTORY_USE_EXTRA_VARS
    ini:
    - key: use_extra_vars
      section: inventory_plugins
    type: bool
    version_added: '2.11'
    version_added_collection: ansible.builtin

use_vars_plugins:
    default: false
    description:
    - Normally, for performance reasons, vars plugins get executed after the inventory
      sources complete the base inventory, this option allows for getting vars related
      to hosts/groups from those plugins.
    - The host_group_vars (enabled by default) 'vars plugin' is the one responsible for
      reading host_vars/ and group_vars/ directories.
    - This will execute all vars plugins, even those that are not supposed to execute
      at the 'inventory' stage. See vars plugins docs for details on 'stage'.
    required: false
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin

leading_separator:
    default: true
    description:
    - Use in conjunction with keyed_groups.
    - By default, a keyed group that does not have a prefix or a separator provided will
      have a name that starts with an underscore.
    - This is because the default prefix is "" and the default separator is "_".
    - Set this option to False to omit the leading underscore (or other separator) if
      no prefix is given.
    - If the group name is derived from a mapping the separator is still used to concatenate
      the items.
    - To not use a separator in the group name at all, set the separator for the keyed
      group to an empty string instead.
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin