Open rmatulat opened 8 years ago
I guess the main problem relies on how salt.utils.dictupdate.update()
is doing the merge.
As long as in a key:value
dict value
is a string, it will be overwritten as expected. If value
is a list
the lists will be added together. So thats why we get doubled entries as discribed above.
I wonder why no one came across this issue before.
Thanks, I will see what's possible!
@rall0r in the short-term you can simply set def_entries to an empty list []
like in https://github.com/bechtoldt/saltstack-network-formula/blob/master/pillar.example.sls#L7 and explictly define all host entries like in https://github.com/bechtoldt/saltstack-network-formula/blob/master/pillar.example.sls#L71
Does it resolve your issue?
I think this is related to the new strategy that salt merges now lists instead of overwriting them. This will require some more work on (almost) all of my formulas.
We tried to overwrite def_entries
, that was our first aproach. Then we realized, that this does not overwrite def_entries
but just merges the defaults.yaml
- def_entries
and the lookup def_entries
together.
I guess I have to write some proof of concept state/pillar and open an issue at saltstack itself.
Nevertheless it would be great if you would come up with some solution :-)
I read your interesting references. That shed some light on that whole "merge" topic. We are using pillar merges quite heavily, so we have to keep an eye on it. But: In case of grains.filter_by merge issues the doc is rather explicit: https://github.com/saltstack/salt/blob/develop/salt/modules/grains.py#L468
Of course this is not something in your responsibility. I guess I'll have to investigate a bit further and see if someone already came up somewhere with the same issues and if not to provide some testcase.
I will update the network formula to my (more or less) new formula structure (like https://github.com/bechtoldt/saltstack-elasticsearch-formula) that uses https://github.com/bechtoldt/salt-modules/blob/master/_modules/formhelper.py which gives us more flexibility when merging pillar with defaults.yaml.
This of course will require users to modify their way how they use my old-styled formulas, but the structure/layout/design/whatever has proven to be very useful for more people.
Hi, I need to disable the IPv6 entries in
/etc/hosts
like they are defined at thedefaults.yaml
. So we need a dict like this:I am unable to overwrite the default values with a pillar because it looks like the key of a pillar
hosts:def_entries
is added tohosts:def_entries
of thedefaults.yaml
.I made a pillar like this:
This leads to a datastructure
hosts
inside yourhosts.sls
like this:As you can see, there are 2
{ip: 127.0.0.1, name: localhost}
entries.Any idea how to fix this? Kind regards ralf