Book Image

Learning SaltStack - Second Edition

By : Myers
Book Image

Learning SaltStack - Second Edition

By: 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 (12 chapters)
11
Index

The highstate


Until now, we have only been running a single state file at a time using state.sls. However, this doesn't scale very well once we have many state files to manage our entire infrastructure. We want to be able to split different pieces of our state into different files to make them more modular. How can we accomplish this?

In the previous chapter, you learned how to target your pillar files to different minions using a top.sls file or topfile. Topfiles can also be used in the state system to target different state files to different minions.

Let's create our topfile now, which is in /srv/salt/top.sls, as follows:

base:
  '*minion':
    - apache
  'os_family:debian':
    - match: grain
    - users_and_ssh

Note that this file is structured almost exactly like the topfile that we used for our pillar data. At the top level (first line), we define our environment. There will be more on environments later—for now, it's enough to note that the default environment is the base environment...