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

An advanced example

Remote execution modules are endlessly flexible. The tools are there, and you can write whatever you need to extend Salt to handle your infrastructure.

However, we're not going to try to explore every possible need your infrastructure might have, as that is impossible to do in the space allotted. Every environment is different, and we have explored the available tools well enough for you to be able to tackle those hurdles on your own.

Instead, we will explore a more complicated example of a remote execution module function from beginning to end and walk through the code.

The example that we will use is file.replace. This remote execution function is designed to replace text in a file based on a pattern. We can set arguments so that if a match is not found, it will prepend or append the text to the file. Here's a full list of arguments in the function declaration:

def replace(path,