Skip to main content

An Ansible lookup plugin that caches the result of any other lookup

Project description

ansible-cached-lookup

An Ansible lookup plugin that caches the results of any other lookup, most useful in group/host vars.

By default, Ansible evaluates any lookups in a group/host var whenever the var is accessed. For example, given a group/host var:

content: "{{ lookup('pipe', 'a-very-slow-command' }}"

any tasks that access content (e.g. in a template) will re-evaluate the lookup, which adds up very quickly. See ansible/ansible#9263.

Installation

  1. Pick a name that you want to use to call this plugin in Ansible playbooks. This documentation assumes you're using the name cached.

    pip install ansible-cached-lookup
    
  2. Create a lookup_plugins directory in the directory in which you run Ansible.

    By default, Ansible will look for lookup plugins in an lookup_plugins folder adjacent to the running playbook. For more information on this, or to change the location where Ansible looks for lookup plugins, see the Ansible docs.

  3. Create a file called cached.py (or whatever name you picked) in the lookup_plugins directory, with one line:

    from ansible_cached_lookup import LookupModule
    

Contributing

To run the tests, run tox.

To format code to pass tox -e lint, run tox -e format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ansible-cached-lookup, version 1.0.0
Filename, size & hash File type Python version Upload date
ansible_cached_lookup-1.0.0-py2.py3-none-any.whl (3.3 kB) View hashes Wheel py2.py3
ansible-cached-lookup-1.0.0.tar.gz (4.9 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page