Book Image

Learning SaltStack

By : Colton Myers
Book Image

Learning SaltStack

By: Colton Myers

Overview of this book

Table of Contents (15 chapters)

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 out different pieces of our state into different files to make them more modular. How can we accomplish this?

In the last 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

Notice 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...