Book Image

Learning SaltStack - Second Edition

By : Colton Myers
Book Image

Learning SaltStack - Second Edition

By: Colton Myers

Overview of this book

SaltStack is one of the best infrastructure management platforms available. It provides powerful tools for defining and enforcing the state of your infrastructure in a clear, concise way. With this book learn how to use these tools for your own infrastructure by understanding the core pieces of Salt. In this book we will take you from the initial installation of Salt, through running their first commands, and then talk about extending Salt for individual use cases. From there you will explore the state system inside of Salt, learning to define the desired state of our infrastructure in such a way that Salt can enforce that state with a single command. Finally, you will learn about some of the additional tools that salt provides, including salt-cloud, the reactor, and the event system. We?ll finish by exploring how to get involved with salt and what'?s new in the salt community. Finally, by the end of the book, you'll be able to build a reliable, scalable, secure, high-performance infrastructure and fully utilize the power of cloud computing.
Table of Contents (17 chapters)
Learning SaltStack Second Edition
About the Author
About the Reviewer

Reacting to events

Now that you've learned how to fire our own custom events, it's time to learn how to react to those events. To accomplish this, we will use a tool, fittingly named the reactor.

The reactor is configured in two parts. The first piece is in the master configuration file and defines which events will trigger which reactor files. The second part consists of the reactor files themselves, which define the actions to be taken when reacting to events, and which are similar to the state files.

Here are the lines we will be adding to our master configuration file (/etc/salt/master):

  - 'salt/custom/*':
    - salt://reactor.sls

Note that globbing is used to target multiple events with a single configuration. Thus, we are now set up so that when the master receives any event that has a tag that starts with salt/custom/, the master will execute the reactor.sls reactor file from our Salt files in /srv/salt.


If multiple event matchers are defined, Salt will check them in order...