Book Image

Learning SaltStack

By : Colton Myers
Book Image

Learning SaltStack

By: Colton Myers

Overview of this book

Table of Contents (15 chapters)

Expanding to encompass multiple pieces of state


We now have our state declaration, which ensures that the apache2 package is installed on each of our minions. However, apache2 will not necessarily be running on our systems.

We know that we can start apache2 using the service.start execution module function, as follows:

# sudo salt '*' service.status apache2
myminion:
    False
# sudo salt '*' service.start apache2
myminion:
    True
# sudo salt '*' service.status apache2
myminion:
    True

Really, we just want to make sure that apache2 is running. Repeatedly running service.start does serve this purpose, but it's not very stateful. Instead, let's use the service.running state module function. Again, note the change in language—rather than starting the service (service.start), we're going to just ensure that it's running (service.running).

Let's first glance at the documentation for this function:

# sudo salt '*' sys.state_doc service.running
myminion:
    ----------
...
    service.running...