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

Get Learning SaltStack now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.