2018-11-29 21:03:00 +01:00
.. _cache_plugins:
2017-09-23 05:19:50 +02:00
Cache Plugins
2018-10-08 19:34:24 +02:00
=============
2017-09-23 05:19:50 +02:00
2018-11-29 21:03:00 +01:00
.. contents ::
:local:
:depth: 2
2017-09-26 00:37:33 +02:00
Cache plugin implement a backend caching mechanism that allows Ansible to store gathered facts or inventory source data
without the performance hit of retrieving them from source.
2017-09-23 05:19:50 +02:00
2018-11-29 21:03:00 +01:00
The default cache plugin is the :ref: `memory <memory_cache>` plugin, which only caches the data for the current execution of Ansible. Other plugins with persistent storage are available to allow caching the data across runs.
2017-09-23 05:19:50 +02:00
2018-10-08 19:34:24 +02:00
You can use a separate cache plugin for inventory and facts. If an inventory-specific cache plugin is not provided and inventory caching is enabled, the fact cache plugin is used for inventory.
2017-09-23 05:19:50 +02:00
2017-10-11 06:15:25 +02:00
.. _enabling_cache:
2018-10-08 19:34:24 +02:00
Enabling Fact Cache Plugins
---------------------------
Only one fact cache plugin can be active at a time.
2017-09-23 05:19:50 +02:00
2017-09-26 00:37:33 +02:00
You can enable a cache plugin in the Ansible configuration, either via environment variable:
2017-09-23 05:19:50 +02:00
.. code-block :: shell
export ANSIBLE_CACHE_PLUGIN=jsonfile
or in the `` ansible.cfg `` file:
.. code-block :: ini
[defaults]
fact_caching=redis
2017-09-26 00:37:33 +02:00
You will also need to configure other settings specific to each plugin. Consult the individual plugin documentation
2018-04-20 02:02:30 +02:00
or the Ansible :ref: `configuration <ansible_configuration_settings>` for more details.
2017-09-23 05:19:50 +02:00
2018-04-20 02:02:30 +02:00
A custom cache plugin is enabled by dropping it into a `` cache_plugins `` directory adjacent to your play, inside a role, or by putting it in one of the directory sources configured in :ref: `ansible.cfg <ansible_configuration_settings>` .
2017-10-11 06:15:25 +02:00
2018-10-08 19:34:24 +02:00
Enabling Inventory Cache Plugins
--------------------------------
Inventory may be cached using a file-based cache plugin (like jsonfile). Check the specific inventory plugin to see if it supports caching.
If an inventory-specific cache plugin is not specified Ansible will fall back to caching inventory with the fact cache plugin options.
The inventory cache is disabled by default. You may enable it via environment variable:
.. code-block :: shell
export ANSIBLE_INVENTORY_CACHE=True
or in the `` ansible.cfg `` file:
.. code-block :: ini
[inventory]
cache=True
or if the inventory plugin accepts a YAML configuration source, in the configuration file:
.. code-block :: yaml
# dev.aws_ec2.yaml
plugin: aws_ec2
cache: True
Similarly with fact cache plugins, only one inventory cache plugin can be active at a time and may be set via environment variable:
.. code-block :: shell
export ANSIBLE_INVENTORY_CACHE_PLUGIN=jsonfile
or in the ansible.cfg file:
.. code-block :: ini
[inventory]
cache_plugin=jsonfile
or if the inventory plugin accepts a YAML configuration source, in the configuration file:
.. code-block :: yaml
# dev.aws_ec2.yaml
plugin: aws_ec2
cache_plugin: jsonfile
Consult the individual inventory plugin documentation or the Ansible :ref: `configuration <ansible_configuration_settings>` for more details.
2017-10-11 06:15:25 +02:00
.. _using_cache:
Using Cache Plugins
2018-10-08 19:34:24 +02:00
-------------------
2017-10-11 06:15:25 +02:00
2017-10-15 18:21:59 +02:00
Cache plugins are used automatically once they are enabled.
2017-10-11 06:15:25 +02:00
.. _cache_plugin_list:
2017-09-23 05:19:50 +02:00
Plugin List
2018-10-08 19:34:24 +02:00
-----------
2017-09-23 05:19:50 +02:00
2017-10-11 06:15:25 +02:00
You can use `` ansible-doc -t cache -l `` to see the list of available plugins.
2017-09-26 00:37:33 +02:00
Use `` ansible-doc -t cache <plugin name> `` to see specific documentation and examples.
2017-09-23 05:19:50 +02:00
.. toctree :: :maxdepth: 1
:glob:
cache/*
.. seealso ::
2018-11-29 21:03:00 +01:00
:ref: `action_plugins`
2017-09-23 05:19:50 +02:00
Ansible Action plugins
2018-11-29 21:03:00 +01:00
:ref: `callback_plugins`
2017-09-23 05:19:50 +02:00
Ansible callback plugins
2018-11-29 21:03:00 +01:00
:ref: `connection_plugins`
2017-09-23 05:19:50 +02:00
Ansible connection plugins
2018-11-29 21:03:00 +01:00
:ref: `inventory_plugins`
2017-09-23 05:19:50 +02:00
Ansible inventory plugins
2018-11-29 21:03:00 +01:00
:ref: `shell_plugins`
2017-09-23 05:19:50 +02:00
Ansible Shell plugins
2018-11-29 21:03:00 +01:00
:ref: `strategy_plugins`
2017-09-23 05:19:50 +02:00
Ansible Strategy plugins
2018-11-29 21:03:00 +01:00
:ref: `vars_plugins`
2017-09-23 05:19:50 +02:00
Ansible Vars plugins
2017-10-15 18:21:59 +02:00
`User Mailing List <https://groups.google.com/forum/#!forum/ansible-devel> `_
2017-09-23 05:19:50 +02:00
Have a question? Stop by the google group!
2017-10-15 18:21:59 +02:00
`webchat.freenode.net <https://webchat.freenode.net> `_
2017-09-23 05:19:50 +02:00
#ansible IRC chat channel