March 2019
Intermediate to advanced
412 pages
9h 49m
English
In addition to rescue, we can also use another section, named always. This section of a block will always be executed irrespective of whether there were errors. This feature is handy for ensuring that the state of a system is always left functional, irrespective of whether a block of tasks was successful. As some tasks of a block may be skipped due to an error, and a rescue section is only executed when there is an error, the always section provides the guarantee of task execution in every instance.
Let's extend our previous example and add an always section to our block:
always: - name: most important task debug: msg: "Never going to let you down"
Rerunning our playbook, we see the additional task displayed:
Read now
Unlock full access