|
|
|
@ -19,6 +19,7 @@ import os
|
|
|
|
|
import glob
|
|
|
|
|
from ansible import errors
|
|
|
|
|
from ansible import utils
|
|
|
|
|
import ansible.constants as C
|
|
|
|
|
|
|
|
|
|
class VarsModule(object):
|
|
|
|
|
|
|
|
|
@ -48,7 +49,11 @@ class VarsModule(object):
|
|
|
|
|
data = utils.parse_yaml_from_file(path)
|
|
|
|
|
if type(data) != dict:
|
|
|
|
|
raise errors.AnsibleError("%s must be stored as a dictionary/hash" % path)
|
|
|
|
|
results.update(data)
|
|
|
|
|
if C.DEFAULT_HASH_BEHAVIOUR == "merge":
|
|
|
|
|
# let data content override results if needed
|
|
|
|
|
results = utils.merge_hash(results, data)
|
|
|
|
|
else:
|
|
|
|
|
results.update(data)
|
|
|
|
|
|
|
|
|
|
# load vars in playbook_dir/group_vars/name_of_host
|
|
|
|
|
path = os.path.join(basedir, "host_vars/%s" % host.name)
|
|
|
|
@ -56,7 +61,10 @@ class VarsModule(object):
|
|
|
|
|
data = utils.parse_yaml_from_file(path)
|
|
|
|
|
if type(data) != dict:
|
|
|
|
|
raise errors.AnsibleError("%s must be stored as a dictionary/hash" % path)
|
|
|
|
|
results.update(data)
|
|
|
|
|
|
|
|
|
|
if C.DEFAULT_HASH_BEHAVIOUR == "merge":
|
|
|
|
|
# let data content override results if needed
|
|
|
|
|
results = utils.merge_hash(results, data)
|
|
|
|
|
else:
|
|
|
|
|
results.update(data)
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|