1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow empty yaml vars files

Fixes #7843
This commit is contained in:
James Cammarata 2014-07-04 22:59:00 -05:00
parent 51e014d915
commit ff04b2b532
3 changed files with 7 additions and 6 deletions

View file

@ -91,10 +91,10 @@ def _load_vars_from_path(path, results, vault_password=None):
# regular file # regular file
elif stat.S_ISREG(pathstat.st_mode): elif stat.S_ISREG(pathstat.st_mode):
data = utils.parse_yaml_from_file(path, vault_password=vault_password) data = utils.parse_yaml_from_file(path, vault_password=vault_password)
if type(data) != dict: if data and type(data) != dict:
raise errors.AnsibleError( raise errors.AnsibleError("%s must be stored as a dictionary/hash" % path)
"%s must be stored as a dictionary/hash" % path) elif data is None:
data = {}
# combine vars overrides by default but can be configured to do a # combine vars overrides by default but can be configured to do a
# hash merge in settings # hash merge in settings
results = utils.combine_vars(results, data) results = utils.combine_vars(results, data)

View file

@ -332,7 +332,6 @@ class Play(object):
if new_default_vars: if new_default_vars:
if type(new_default_vars) != dict: if type(new_default_vars) != dict:
raise errors.AnsibleError("%s must be stored as dictionary/hash: %s" % (filename, type(new_default_vars))) raise errors.AnsibleError("%s must be stored as dictionary/hash: %s" % (filename, type(new_default_vars)))
default_vars = utils.combine_vars(default_vars, new_default_vars) default_vars = utils.combine_vars(default_vars, new_default_vars)
return default_vars return default_vars

View file

@ -44,8 +44,10 @@ class ActionModule(object):
if os.path.exists(source): if os.path.exists(source):
data = utils.parse_yaml_from_file(source, vault_password=self.runner.vault_pass) data = utils.parse_yaml_from_file(source, vault_password=self.runner.vault_pass)
if type(data) != dict: if data and type(data) != dict:
raise errors.AnsibleError("%s must be stored as a dictionary/hash" % source) raise errors.AnsibleError("%s must be stored as a dictionary/hash" % source)
elif data is None:
data = {}
result = dict(ansible_facts=data) result = dict(ansible_facts=data)
return ReturnData(conn=conn, comm_ok=True, result=result) return ReturnData(conn=conn, comm_ok=True, result=result)
else: else: