ansible.builtin.config (v2.9.18) — lookup

Lookup current Ansible configuration values

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

Authors: Ansible Core

Install Ansible via pip

Install with pip install ansible==2.9.18

Description

Retrieves the value of an Ansible configuration setting.

You can use C(ansible-config list) to see all available settings.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: Show configured default become user
      debug: msg="{{ lookup('config', 'DEFAULT_BECOME_USER')}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: print out role paths
      debug:
        msg: "These are the configured role paths: {{lookup('config', 'DEFAULT_ROLES_PATH')}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: find retry files, skip if missing that key
      find:
        paths: "{{lookup('config', 'RETRY_FILES_SAVE_PATH')|default(playbook_dir, True)}}"
        patterns: "*.retry"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: see the colors
      debug: msg="{{item}}"
      loop: "{{lookup('config', 'COLOR_OK', 'COLOR_CHANGED', 'COLOR_SKIP', wantlist=True)}}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    - name: skip if bad value in var
      debug: msg="{{ lookup('config', config_in_var, on_missing='skip')}}"
      var:
        config_in_var: UNKNOWN

Inputs

    
_terms:
    description: The key(s) to look up
    required: true

on_missing:
    choices:
    - error
    - skip
    - warn
    default: error
    description:
    - action to take if term is missing from config
    - Error will raise a fatal error
    - Skip will just ignore the term
    - Warn will skip over it but issue a warning
    type: string

Outputs

_raw:
  description:
  - value(s) of the key(s) in the config