From daef6f0911c206707b088e4ce75ea660fc928c74 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 24 May 2017 09:31:44 -0400 Subject: [PATCH] allow empty files in host/group_vars also remove unused import fixes #24963 --- lib/ansible/plugins/vars/host_group_vars.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/vars/host_group_vars.py b/lib/ansible/plugins/vars/host_group_vars.py index 19bf2bbedd..4b1280ae49 100644 --- a/lib/ansible/plugins/vars/host_group_vars.py +++ b/lib/ansible/plugins/vars/host_group_vars.py @@ -36,7 +36,6 @@ from ansible import constants as C from ansible.errors import AnsibleParserError from ansible.module_utils._text import to_bytes, to_text from ansible.plugins.vars import BaseVarsPlugin -from ansible.utils.path import basedir from ansible.inventory.host import Host from ansible.inventory.group import Group from ansible.utils.vars import combine_vars @@ -71,7 +70,9 @@ class VarsModule(BaseVarsPlugin): self._display.debug("\tprocessing dir %s" % opath) for found in self._find_vars_files(opath, entity.name): self._display.debug("READING %s" % found) - data = combine_vars(data, loader.load_from_file(found, cache=True, unsafe=True)) + new_data = loader.load_from_file(found, cache=True, unsafe=True) + if new_data: # ignore empty files + data = combine_vars(data, new_data) else: self._display.warning("Found %s that is not a directory, skipping: %s" % (subdir, opath))