Book Image

Learning SaltStack

By : Colton Myers
Book Image

Learning SaltStack

By: Colton Myers

Overview of this book

Table of Contents (15 chapters)

Dependencies using requisites

These states will run in the order they are defined in the file by default. However, we can also affect the ordering using requisites. Requisites allow us to create dependencies and interactions between our states.

The require requisite

The most basic requisite is require, which allows you to specify that one state requires another state to be run successfully first. Make sure you note both purposes—the require requisite both ensures correct ordering, and ensures that the requiring states runs only if the required state ran successfully.

In this case, we want to make sure that apache is installed before we try to run it. Thus, we will add a require requisite declaration under our service.running state, as shown here:

    - name: apache2

make sure apache is running:
    - name: apache2
    - enable: True
    - require:
      - pkg: install_apache

Note that we must specify both the state module pkg and the state...