Skip to content

Instantly share code, notes, and snippets.

@eofs
Last active April 10, 2019 14:02
Show Gist options
  • Save eofs/0219728e6f89e6e7b860 to your computer and use it in GitHub Desktop.
Save eofs/0219728e6f89e6e7b860 to your computer and use it in GitHub Desktop.
Remove keys of disconnected Saltstack minions
# Enable "presence" events
# - http://docs.saltstack.com/en/latest/ref/configuration/master.html#presence-events
# - http://docs.saltstack.com/en/latest/topics/event/master_events.html#presence-events
presence_events: True
reactor:
# Note: This tag has a typo in it (version 2014.1.5), subject to change!
- 'salt/presense/change':
- /srv/reactor/presence.sls
{% for minion_id in data['lost'] %}
remove_unused_keys:
wheel.key.delete:
- match: {{ minion_id }}
{% endfor %}
@Inveracity
Copy link

Inveracity commented Apr 25, 2017

to those that find this using google, here's an updated version without the typo from version 2014.1.5
the following is confirmed working in 2016.11.3:

reactor:
  - 'salt/presence/change':
    - /srv/reactor/presence.sls
{% for minion_id in data['lost'] %}
remove_unused_keys_{{ minion_id }}: # avoid duplicate key error
  wheel.key.delete:
    - match: {{ minion_id }}
{% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment