Fixing new caching related issue with host vars
The vars_cache was not being properly merged with the setup_cache for all hosts, which was previously not noticed when registered variables were stored in the setup_cache. Fixes #8944
This commit is contained in:
parent
0179c13e04
commit
10afaee108
5 changed files with 20 additions and 2 deletions
3
lib/ansible/cache/base.py
vendored
3
lib/ansible/cache/base.py
vendored
|
@ -36,3 +36,6 @@ class BaseCacheModule(object):
|
|||
|
||||
def flush(self):
|
||||
raise exceptions.NotImplementedError
|
||||
|
||||
def copy(self):
|
||||
raise exceptions.NotImplementedError
|
||||
|
|
3
lib/ansible/cache/memcached.py
vendored
3
lib/ansible/cache/memcached.py
vendored
|
@ -186,3 +186,6 @@ class CacheModule(BaseCacheModule):
|
|||
def flush(self):
|
||||
for key in self.keys():
|
||||
self.delete(key)
|
||||
|
||||
def copy(self):
|
||||
return self._keys.copy()
|
||||
|
|
7
lib/ansible/cache/memory.py
vendored
7
lib/ansible/cache/memory.py
vendored
|
@ -15,7 +15,9 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class CacheModule(object):
|
||||
from ansible.cache.base import BaseCacheModule
|
||||
|
||||
class CacheModule(BaseCacheModule):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._cache = {}
|
||||
|
@ -37,3 +39,6 @@ class CacheModule(object):
|
|||
|
||||
def flush(self):
|
||||
self._cache = {}
|
||||
|
||||
def copy(self):
|
||||
return self._cache.copy()
|
||||
|
|
7
lib/ansible/cache/redis.py
vendored
7
lib/ansible/cache/redis.py
vendored
|
@ -93,3 +93,10 @@ class CacheModule(BaseCacheModule):
|
|||
def flush(self):
|
||||
for key in self.keys():
|
||||
self.delete(key)
|
||||
|
||||
def copy(self):
|
||||
# FIXME: there is probably a better way to do this in redis
|
||||
ret = dict()
|
||||
for key in self.keys():
|
||||
ret[key] self.get(key)
|
||||
return ret
|
||||
|
|
|
@ -598,7 +598,7 @@ class Runner(object):
|
|||
|
||||
# merge the VARS and SETUP caches for this host
|
||||
combined_cache = self.setup_cache.copy()
|
||||
combined_cache.setdefault(host, {}).update(self.vars_cache.get(host, {}))
|
||||
combined_cache.update(self.vars_cache)
|
||||
|
||||
hostvars = HostVars(combined_cache, self.inventory, vault_password=self.vault_pass)
|
||||
|
||||
|
|
Loading…
Reference in a new issue