saltstack/salt — pull request #16767 by plastikos (2014-10-20 22:23:30+00:00)
Title: Add a "base" dictionary argument to grains:filter_by()

The base argument provides a base dictionary for default settings.
The grain-selected look_up dictionary is then merged over the top of
base followed by the merge dictionary being merged. The base allows
for common settings in each of the look_up groups to be collected into
the base so that they do not have to be repeated for each group.

example1:

salt '*' grains.filter_by '{A: {B: Z}, C: {D: {E: F,G: H}}}' 'xxx' '{D: {E: I},J: K}' 'C' '{D: {E: X}, L: M}'

result1:

{D: {E: I, G: H}, J: K, L: M}

example2:

The same as example1 but with default selector 'A' rather than 'C'.

result2:

{B: Z, D: {E: I}, J: K, L: M}