Attach a condition to any step or action to decide at runtime whether it should run. A condition is a mustache expression that can reference outputs from earlier steps, workflow variables, or any other data in the execution context.Using conditions, you can introduce decision-making into workflows by asserting values, thresholds, or specific states.
Simple if condition
actions: - name: notify-slack if: "{{ alert.cpu_load }} == '70'" provider: type: slack config: "{{ providers.slack }}" with: message: "The CPU load exceeded the threshold!"
Values of variables will be quoted when evaluated. For example, if
alert.cpu_load is 70, it will resolve to '70' (number quoted with single
quotes).
Using results of other steps in condition
workflow: id: query-and-alert description: "Query a database and notify only if a threshold is met" steps: - name: get-disk-usage provider: type: mysql config: "{{ providers.mysql-prod }}" with: query: "SELECT disk_usage FROM metrics WHERE server = 'db1'" single_row: true actions: - name: notify-slack if: "{{ steps.get-disk-usage.results.disk_usage }} > 90" provider: type: slack config: "{{ providers.slack }}" with: message: "Disk usage is critical: {{ steps.get-disk-usage.results.disk_usage }}%"