ansible.builtin.script – Executes an inventory script that returns JSON

Note

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

New in version 2.4: of ansible.builtin

Synopsis

  • The source provided must be an executable that returns Ansible inventory JSON

  • The source must accept --list and --host <hostname> as arguments. --host will only be used if no _meta key is present. This is a performance optimization as the script would be called per host otherwise.

Parameters

Parameter

Comments

always_show_stderr

boolean

added in 2.5.1 of ansible.builtin

Toggle display of stderr even when script was successful

Choices:

  • no

  • yes ← (default)

Configuration:

  • INI entry:

    [inventory_plugin_script]
    always_show_stderr = yes
    
  • Environment variable: ANSIBLE_INVENTORY_PLUGIN_SCRIPT_STDERR

cache

string

Removed in: version 2.12

Why: This option has never been in use. External scripts must implement their own caching.

Alternative:

This option has no effect. The plugin will not cache results because external inventory scripts are responsible for their own caching. This option will be removed in 2.12.

Configuration:

  • INI entry:

    [inventory_plugin_script]
    cache = None
    
  • Environment variable: ANSIBLE_INVENTORY_PLUGIN_SCRIPT_CACHE

Notes

Note

  • Whitelisted in configuration by default.

  • The plugin does not cache results because external inventory scripts are responsible for their own caching.