From cf00883c9d7987331e786a9eb13a0564c338f90a Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Tue, 28 May 2019 18:44:00 +0100 Subject: [PATCH] Return results even when the cache is disabled (#55505) * Return results even when the cache is disabled By default the cache is disabled and so the results of the API call are not placed in there for the return statement to fetch. * Always update self._cache to return --- changelogs/fragments/55505-foreman-inventory.yaml | 2 ++ lib/ansible/plugins/inventory/foreman.py | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/55505-foreman-inventory.yaml diff --git a/changelogs/fragments/55505-foreman-inventory.yaml b/changelogs/fragments/55505-foreman-inventory.yaml new file mode 100644 index 0000000000..1248ee5a2c --- /dev/null +++ b/changelogs/fragments/55505-foreman-inventory.yaml @@ -0,0 +1,2 @@ +bugfixes: + - Fix foreman inventory plugin when inventory caching is disabled diff --git a/lib/ansible/plugins/inventory/foreman.py b/lib/ansible/plugins/inventory/foreman.py index ebcdff9386..c7512ce98b 100644 --- a/lib/ansible/plugins/inventory/foreman.py +++ b/lib/ansible/plugins/inventory/foreman.py @@ -162,9 +162,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable): # get next page params['page'] += 1 - # Set the cache if it is enabled or if the cache was refreshed - if self.use_cache or self.get_option('cache'): - self._cache[self.cache_key][url] = results + self._cache[self.cache_key][url] = results return self._cache[self.cache_key][url]