Fix inventory cache interface (#50446)

* Replace InventoryFileCacheModule with a better developer-interface

Use new interface for inventory plugins with backwards compatibility

Auto-update the backing cache-plugin if the cache has changed after parsing the inventory plugin

* Update CacheModules to use the config system and add a deprecation warning if they are being imported directly rather than using cache_loader

* Fix foreman inventory caching

* Add tests

* Add integration test to check that fact caching works normally with cache plugins using ansible.constants and inventory caching provides a helpful error for non-compatible cache plugins

* Add some developer documentation for inventory and cache plugins

* Add user documentation for inventory caching

* Add deprecation docs

* Apply suggestions from docs review

* Add changelog
This commit is contained in:
Sloane Hertel 2019-03-06 12:12:35 -06:00 committed by GitHub
commit 9687879840
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 831 additions and 86 deletions

View file

@ -193,6 +193,19 @@ Deprecated
removed in 2.12. If you need the old behaviour switch to ``FactCache.first_order_merge()``
instead.
* Supporting file-backed caching via self.cache is deprecated and will
be removed in Ansible 2.12. If you maintain an inventory plugin, update it to use ``self._cache`` as a dictionary. For implementation details, see
the :ref:`developer guide on inventory plugins<inventory_plugin_caching>`.
* Importing cache plugins directly is deprecated and will be removed in Ansible 2.12. Use the plugin_loader
so direct options, environment variables, and other means of configuration can be reconciled using the config
system rather than constants.
.. code-block:: python
from ansible.plugins.loader import cache_loader
cache = cache_loader.get('redis', **kwargs)
Modules
=======
@ -336,6 +349,8 @@ Plugins
* ``osx_say`` callback plugin was renamed into :ref:`say <say_callback>`.
* Inventory plugins now support caching via cache plugins. To start using a cache plugin with your inventory see the section on caching in the :ref:`inventory guide<using_inventory>`. To port a custom cache plugin to be compatible with inventory see :ref:`developer guide on cache plugins<developing_cache_plugins>`.
Porting custom scripts
======================