You'll learn how to:
Estimated time: 15 minutes
Difficulty:
One of the most important (and complex) aspects of configuration management is making sure that each task is executed at the correct time.
By default, each ID in a Salt state file is executed in the order it appears in the file. Additionally, in the Top file, each Salt state file is applied in the order listed. For example, the state IDs in the following diagram run in sequential order as a result of the organization of the Top file and Salt state files:
By organizing the Salt states that you want applied in this order, you can control execution order without explicitly defining dependencies.
Requisites let you explicitly specify the dependencies for an ID in a state. If you add a statement that indicates id1
requires id4
, id4
is applied first.
You can use the state.show_sls
execution function to view the order in which Salt states are applied. For example:
salt 'minion1' state.show_sls sls1[,sls2,...]
To view the order in which Salt states are applied from the examples.sls
file you created earlier:
salt 'minion1' state.show_sls examples
There are several other statements you can use to control execution order. You can find details in Requisites and other Global State Arguments.