mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Pillar overwrite merge stategy
This commit is contained in:
parent
ad4c662946
commit
cca7b80786
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user