Pillar overwrite merge stategy

This commit is contained in:
Mike Place 2014-10-10 16:25:53 -06:00
parent ad4c662946
commit cca7b80786

View File

@ -34,6 +34,13 @@ def merge_recurse(obj_a, obj_b):
def merge_aggregate(obj_a, obj_b):
return merge_recursive(obj_a, obj_b, level=1)
def merge_overwrite(obj_a, obj_b):
for obj in obj_b:
if obj in obj_a.keys():
obj_a[obj] = obj_b[obj]
return obj_a
else:
return merge_recurse(obj_a, obj_b)
def get_pillar(opts, grains, id_, saltenv=None, ext=None, env=None):
'''
@ -552,6 +559,8 @@ class Pillar(object):
elif strategy == 'aggregate':
#: level = 1 merge at least root data
merged = merge_aggregate(obj_a, obj_b)
elif strategy == 'overwrite':
merged = merge_overwrite(obj_a, obj_b)
else:
log.warning('unknown merging strategy {0}, '
'fallback to recurse'.format(strategy))