Don't fail if hieradata(_file) are not set

Change-Id: I92c5e317ba6ffb3b1f0de4d8816ff43f7e42c064
This commit is contained in:
Flavio Percoco 2017-12-04 10:09:05 +01:00
parent df57305287
commit 569dacfed6
2 changed files with 11 additions and 4 deletions

View File

@ -4,6 +4,6 @@ namespace: openstack
# TripleO
default: {}
schema: {}
hieradata: {}
hieradata_file: '/etc/puppet/hieradata/service_configs.json'
hieradata:
hieradata_file:
fact_variable: ''

View File

@ -86,8 +86,15 @@ def main():
hieradata = module.params['hieradata']
hieradata_file = module.params['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 not hieradata and not hieradata_file:
module.exit_json(**{'changed': False, 'conf_dict': {}})
if hieradata is None and (hieradata_file and
os.path.exists(hieradata_file)):
msg = "Data file {data_file} doesn't exist".format(
data_file=hieradata_file)
module.fail_json(msg=msg)
if os.path.exists(hieradata_file):
# NOTE(flaper87): This will load both, json and yaml, files