diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index a99f5a3e318..1bf0ea10b6e 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -101,7 +101,10 @@ class CacheModule(BaseCacheModule): else: f.write(jsonify(value)) finally: - f.close() + try: + f.close() + except UnboundLocalError: + pass def has_expired(self, key):