O'Reilly logo

Salt Cookbook by Anirban Saha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listening to events

Out of the two procedures of a Salt event system, one is listening to Salt events. In this chapter, we will learn about the different procedures to listen for Salt events.

How to do it...

  1. On the Salt master, create a file anywhere called cookbookeventslisten.py and edit it so it has the following content:
    #!/usr/bin/python import salt.config import salt.utils.event import time import pprint opts = salt.config.client_config('/etc/salt/master') event = salt.utils.event.get_event( 'master', sock_dir=opts['sock_dir'], transport=opts['transport'], opts=opts) response = event.get_event(wait=30, tag='cookbook/test') print('Event fired at {0}'.format(time.asctime())) print('*' * 25) print('Tag: {0}'.format(response['tag'])) print('Data:') ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required