From dd4ca66e1e4dd0a0514aa0989acfa49143939dd4 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 6 Nov 2015 22:21:50 -0500 Subject: [PATCH] Make sure hostvars cache is recreated during serialization --- lib/ansible/vars/hostvars.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ansible/vars/hostvars.py b/lib/ansible/vars/hostvars.py index b4cd5eeaf4..f56f542574 100644 --- a/lib/ansible/vars/hostvars.py +++ b/lib/ansible/vars/hostvars.py @@ -51,7 +51,7 @@ class HostVars(collections.Mapping): self._loader = loader self._play = play self._variable_manager = variable_manager - self._cached_result = {} + self._cached_result = dict() hosts = inventory.get_hosts(ignore_limits_and_restrictions=True) @@ -106,10 +106,16 @@ class HostVars(collections.Mapping): return len(self._lookup) def __getstate__(self): - return dict(loader=self._loader, lookup=self._lookup, play=self._play, var_manager=self._variable_manager) + return dict( + loader=self._loader, + lookup=self._lookup, + play=self._play, + var_manager=self._variable_manager, + ) def __setstate__(self, data): self._play = data.get('play') self._loader = data.get('loader') self._lookup = data.get('lookup') self._variable_manager = data.get('var_manager') + self._cached_result = dict()