Cache Plugins
The default cache plugin is the memory 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.
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.
Only one fact cache plugin can be active at a time.
You can enable a cache plugin in the Ansible configuration, either via environment variable:
or in the file:
- [defaults]
- fact_caching=redis
A custom cache plugin is enabled by dropping it into a directory adjacent to your play, inside a role, or by putting it in one of the directory sources configured in .
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:
or in the file:
- [inventory]
- cache=True
or if the inventory plugin accepts a YAML configuration source, in the configuration file:
- export ANSIBLE_INVENTORY_CACHE_PLUGIN=jsonfile
or in the ansible.cfg file:
or if the inventory plugin accepts a YAML configuration source, in the configuration file:
- # dev.aws_ec2.yaml
- plugin: aws_ec2
Consult the individual inventory plugin documentation or the Ansible configuration for more details.
Cache plugins are used automatically once they are enabled.
You can use to see the list of available plugins.Use to see specific documentation and examples.
- memcached – Use memcached DB for cache
- mongodb – Use MongoDB for caching
- redis – Use Redis DB for cache
- Action Plugins
- Ansible Action plugins
- Ansible callback plugins
- Connection Plugins
- Ansible inventory plugins
- Shell Plugins
- Ansible Shell plugins
- Ansible Strategy plugins
- Vars Plugins
- Ansible Vars plugins
- Have a question? Stop by the google group!
- webchat.freenode.net
ansible IRC chat channel