From 3e754086b65386f982f6cf4fc1871eb04e1928da Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Fri, 16 Sep 2016 15:08:02 -0400 Subject: [PATCH] Fix error using jsonfile with incomplete config (#17567) If 'fact_caching=jsonfile' was configured, but 'fact_caching_connection' was not configured, jsonfile would fail and ansible-playbook would exit with a traceback. Fixes #17566 --- lib/ansible/plugins/cache/jsonfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index 02a91c34a4..e1669068fc 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -50,7 +50,11 @@ class CacheModule(BaseCacheModule): self._timeout = float(C.CACHE_PLUGIN_TIMEOUT) self._cache = {} - self._cache_dir = os.path.expanduser(os.path.expandvars(C.CACHE_PLUGIN_CONNECTION)) + self._cache_dir = None + + if C.CACHE_PLUGIN_CONNECTION: + # expects a dir path + self._cache_dir = os.path.expanduser(os.path.expandvars(C.CACHE_PLUGIN_CONNECTION)) if not self._cache_dir: raise AnsibleError("error, 'jsonfile' cache plugin requires the 'fact_caching_connection' config option to be set (to a writeable directory path)")