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', sock_dir, transport, listen=False, ) event.fire_event(data_dict, some_tag)
Let's go over what happened here. First, we set up our imports. The salt.syspaths
library...