How to join two Salt pillar files and merge data?
salt-stack
Solution
It is possible at least according to the latest Salt documentation about pillar (as of `5188d6c`) which states:
With some care, the pillar namespace can merge content from multiple pillar files under a single key, so long as conflicts are avoided ...
I tested it under Salt Helium (`2014.7.0`) and it's working as expected.
Your Example
Pillar file `user_set_a.sls`:
users:
joe:
sudouser: True
jack:
sudouser: False
Pillar file `user_set_b.sls`:
users:
new_user:
sudouser: True
Run `pillar.items` to confirm that all users are merged under the same `users` key:
salt-call pillar.items
...
users:
----------
jack:
----------
sudouser:
False
joe:
----------
sudouser:
True
new_user:
----------
sudouser:
True
...
See also:
- Example to include pillar files under sub-keys: https://serverfault.com/a/591501/134406
Problem
Is there any way to join two pillar files? I have a users pillar. It's something like: ``` users: joe: sudouser: True jack: sudouser: False ``` Now I need different set of users for certain servers (ie. add some users to one server). So I create new pillar file: ``` users: new_user: sudouser: True ``` And assign this topfile to the server. But because the key is the same it would overwrite the first one. If I change it I would need to update the state file (which I really don't want). How should I approach this problem? Is there any way to tell salt to "merge" the files?