Support default values

This commit is contained in:
Flavio Percoco 2017-08-21 15:48:06 +02:00
parent 3332abcc85
commit 735ada9503
3 changed files with 4 additions and 1 deletions

View File

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

View File

@ -78,6 +78,7 @@ def main():
hieradata=dict(type='dict', default={}),
hieradata_file=dict(type='str', default=''),
schema=dict(type='dict'),
default=dict(type='dict'),
),
supports_check_mode=True)
@ -92,7 +93,7 @@ def main():
# NOTE(flaper87): This will load both, json and yaml, files
hieradata = yaml.safe_load(open(hieradata_file))
conf_dict = {}
conf_dict = module.params['default']
for key, mapping in schema.items():
if key not in hieradata:
continue

View File

@ -3,6 +3,7 @@
hieradata_file: '{{ hieradata_file }}'
hieradata: '{{ hieradata }}'
schema: '{{ schema }}'
default: '{{default}}'
when:
- hieradata or hieradata_file
- schema