ansible.builtin.config – Lookup current Ansible configuration values

From Get docs
Ansible/docs/2.10/collections/ansible/builtin/config lookup


ansible.builtin.config – Lookup current Ansible configuration values

Note

This module is part of ansible-base and included in all Ansible installations. In most cases, you can use the short module name config even without specifying the collections: keyword. Despite that, we recommend you use the FQCN for easy linking to the module documentation and to avoid conflicting with other collections that may have the same module name.


New in version 2.5: of ansible.builtin


Synopsis

  • Retrieves the value of an Ansible configuration setting.
  • You can use ansible-config list to see all available settings.

Parameters

Parameter Choices/Defaults Configuration Comments

_terms

string / required

The key(s) to look up

on_missing

string

  • error

  • skip
  • warn

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



Examples

- name: Show configured default become user
  debug: msg="{{ lookup('config', 'DEFAULT_BECOME_USER')}}"

- name: print out role paths
  debug:
    msg: "These are the configured role paths: {{lookup('config', 'DEFAULT_ROLES_PATH')}}"

- name: find retry files, skip if missing that key
  find:
    paths: "{{lookup('config', 'RETRY_FILES_SAVE_PATH')|default(playbook_dir, True)}}"
    patterns: "*.retry"

- name: see the colors
  debug: msg="{{item}}"
  loop: "{{lookup('config', 'COLOR_OK', 'COLOR_CHANGED', 'COLOR_SKIP', wantlist=True)}}"

- name: skip if bad value in var
  debug: msg="{{ lookup('config', config_in_var, on_missing='skip')}}"
  var:
    config_in_var: UNKNOWN

Authors

  • Ansible Core Team

There were some errors parsing the documentation for this plugin. Please file a bug with the collection.

The errors were:

  • Unable to normalize config: return due to: 1 validation error for PluginReturnSchema
    return -> _raw -> type
      string does not match regex "^(bool|complex|dict|float|int|list|str)$" (type=value_error.str.regex; pattern=^(bool|complex|dict|float|int|list|str)$)

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/ansible/builtin/config_lookup.html