Fix bug and set default for hieradata_file

Make hieradata_file point to /etc/puppet/hieradata/service_configs.json
since this is a tripleo module anyway and we can assume the file is
there for most cases.
This commit is contained in:
Flavio Percoco 2017-07-28 17:48:41 +02:00
parent e1f200c2ba
commit 038278f734
2 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
schema: {}
hieradata: {}
hieradata_file: ''
hieradata_file: '/etc/puppet/hieradata/service_configs.json'
fact_variable: ''

View File

@ -85,11 +85,12 @@ def main():
hieradata = module.params['hieradata']
hieradata_file = module.params['hieradata_file']
if not (hieradata or hieradata_file):
if not (hieradata or (hieradata_file and os.path.exists(hieradata_file))):
module.fail_json(msg="Either hieradata or hieradata_file must be set")
if os.path.exists(hieradata_file):
hieradata = yaml.safe_load(hieradata_file)
# NOTE(flaper87): This will load both, json and yaml, files
hieradata = yaml.safe_load(open(hieradata_file))
conf_dict = {}
for key, mapping in schema.items():