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

The Salt event system

Events are an integral part of almost everything Salt does. However, for the most part, these events are designed to be invisible and are designed to work behind the scenes to provide interprocess communication and make a complex system feel simple and friendly to the user.

We can also leverage the event system for our own purposes.

Listening for events

Before you learn about reacting to events or firing our own, let's inspect some of these events that are happening all the time in Salt. A Salt runner function (state.event) is provided for this purpose.

If we run it with no arguments, it will automatically connect to the master event bus and print all events that come through that bus:

# sudo salt-run state.event

Note that if you don't see any events, the easiest way to create events is by running a job (such as from your master.

Here is the job I ran in one terminal window while state.event was running in another:

# sudo salt '*'