Functionality - While Loops
This type of loop repeats one or more operations until a condition is met.
The condition should be a single Python expression
Its output must be True or False
Read more about while loops on w3schools.
Steps & Actions
This example repeats an action until the Task Operator chooses No.
- An action gives the Task Operator a choice & outputs True or False
- Its output is saved as the
- The until expression will exit the loop when
1 2 3 4 5 6 7
Jinja2 is supported here, but the examples use Python to match other Playbook expressions.
Action output is saved normally inside while loops (provided the action is not sequenced).
In the example above, the action is inside a while loop that could repeat indefinitely.
repeat variable will always contain the value of the most recent run.
While loops can repeat indefinitely!
Make sure your until expression outputs True in at least one scenario.
Variables in Expressions
All variables in the expression must exist when the expression is evaluated.
If any variables have not been set, the task will fail with this type of message:
'until' expression variable 'confirm' has not been set globally or saved by any action