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.

Source Distribution

ansible-cached-lookup-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

ansible_cached_lookup-1.0.0-py2.py3-none-any.whl (3.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ansible-cached-lookup-1.0.0.tar.gz.

File metadata

  • Download URL: ansible-cached-lookup-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for ansible-cached-lookup-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64c3009d6f64aa32dc738332bec02add3eeb57c0636215a4bb678dc352bf7a6a
MD5 f1cb66da947eeb040488e2aa2bc0d85f
BLAKE2b-256 b57c19665493a4f7637a413ff15a1b981bbbd847886c168b6844d9cb0d96fe8d

See more details on using hashes here.

File details

Details for the file ansible_cached_lookup-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ansible_cached_lookup-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for ansible_cached_lookup-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cb59a1dd4525513e11a89afe1821df829fbd566b0f37e3d330b8a41d6a52a810
MD5 9436bbb80d6217b428271cca82ae0000
BLAKE2b-256 e030293d3610adf4c11f13dee7c0fd32279b5df90a937de13cc283d2ea7e236b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page