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