Firing events

You can fire events both from the Minion-side modules (such as execution and state modules) and Master-side modules (such as runners). From a Minion-side module, you need nothing more than to call out to the event execution module as follows:

__salt__['event.fire_master'](data_dict, some_tag)

But in Master-side modules, you need to do a little more work, since __salt__ isn't available. You need to import salt.utils.event, then use it to fire the event. This isn't much more work, but you do have to do some setup. It looks like:

import os.path import salt.utils.event import salt.syspaths sock_dir = os.path.join(salt.syspaths.SOCK_DIR, 'master') transport = __opts__.get('transport', 'zeromq') event = salt.utils.event.get_event( 'master', ...

Get Extending SaltStack now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.