Chapter 13. State Machines

We have mentioned workflows several times in the preceding chapters. A workflow can be simply defined as a sequence of operations or steps that make up a work process. Many tasks that we perform as cloud or systems administrators can be broken down into simple workflow steps:

  1. Do something.

  2. Do something.

  3. Do something.

CloudForms Automate allows us to add intelligence to our workflow steps by defining steps as states. Each state is capable of performing pre and postprocessing around the main task, and can handle and potentially recover from errors that occur while performing the task (see Table 13-1). Individual states can enter a retry loop, with the maximum number of retries and overall timeout for the state being definable.

Table 13-1. Adding intelligence to workflow steps via states
Step On entry Task On exit On error

1

Preprocess before doing something.

Do something.

Postprocess after doing something.

Handle any errors while doing something.

2

Preprocess before doing something.

Do something.

Postprocess after doing something.

Handle any errors while doing something.

3

Preprocess before doing something.

Do something.

Postprocess after doing something.

Handle any errors while doing something.

When we assemble several of these intelligent states together, it becomes an Automate state machine. The logic flow through an Automate state machine is shown in Figure 13-1.

Figure 13-1. Simple Automate state machine workflow

Building ...

Get Mastering CloudForms Automation now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.