Salt: Pillar salt events on changes

Created on 28 Feb 2017  路  8Comments  路  Source: saltstack/salt

Would be nice to have events to watch for pillar changes.

My use case is the following:
I dynamically manage my nodes with "roles" I give them through their pillar as follow :

[root@dbk-mastery-01v srv]$ cat pillar/nodes/init.sls
{% include 'nodes/' + salt['grains.get']('host') + '.sls' ignore missing %}
[root@dbk-mastery-01v srv]$ cat pillar/nodes/dbk-miniont-01v.sls
roles:
  - swarm.manager



md5-33e4788f3ae5edb7bcf204c27ebb5666



[root@dbk-mastery-01v srv]$ cat salt/roles/init.sls
{% if 'roles' in pillar %}
include:
{% for role in salt['pillar.get']('roles', []) %}
  - {{ role }}
{% endfor %}
{% endif %}

This works nicely, but it would be even better if I can apply the absent state (state that removes what init state did) when I remove an entry in pillar roles list.

Core Feature Pillar stale

Most helpful comment

Will approve as a feature request. Thanks!

All 8 comments

@mfilotto did you have a look at this beacon: https://docs.saltstack.com/en/latest/ref/beacons/all/salt.beacons.inotify.html? You can configure it to push events on the bus when a file is changed. You could monitor dbk-miniont-01v.sls etc. and using a reactor you can execute the necessary state. Is this suitable for your case?

@mfilotto did you see @mirceaulinic 's suggestion. Does that work for our use case?

@mirceaulinic : Does the inotify event contain the diff or new and old file versions for me to compare and trigger my absent state ?

Not what I'm aware of @mfilotto.

Could adding pillar change events be considered ?

That would be a very nice feature indeed. +1

Will approve as a feature request. Thanks!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Oloremo picture Oloremo  路  3Comments

twangboy picture twangboy  路  3Comments

golmaal picture golmaal  路  3Comments

saurabhnemade picture saurabhnemade  路  3Comments

lhost picture lhost  路  3Comments