Skip to main content

Actions

Actions are the fundamental tasks executed by a playbook. A playbook can comprise multiple actions, which are executed sequentially. If any action encounters an error and fails, the execution of the playbook is halted.

FieldDescriptionSchemeRequired
nameName of action.stringtrue
runsOnSpecify the runners that can run this action. One will be chosen on random. When empty, the playbook will run on the main instance itself[]string
templatesOnSpecify where the templating of the action spec should occurhost or agent
delayA delay before running the action e.g. 8hDuration or Expression
filterWhether to run the step or notExpression
timeoutTimeout on this action.Duration
azureDevopsPipelineAzureDevops
execSpecify exec of action.Exec
gitopsSpecify gitops of action.Gitops
httpSpecify http of action.Http
sqlSpecify sql of action.Sql`
podSpecify pod of action.Pod
notificationSpecify notification of action.Notification
note

Specify one or more actions; but at least one.

Templating

Templating allows your playbook actions to work in context of a config, health check or a component.

scale-deployment.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: scale-deployment
spec:
description: Scale deployment
configs:
- types: [Kubernetes::Deployment]
parameters:
- name: replicas
label: The new desired number of replicas.
actions:
- name: scale deployment
exec:
script: kubectl scale --replicas={{.params.replicas}} --namespace={{.config.tags.namespace}} deployment {{.config.name}}

Accessing results of another action

You can base your filters based on result of a previous action. The following two cel functions can be used:

getLastAction

getLastAction() returns the result of the action that ran just before this action.

Syntax:

getLastAction().result.stdout.JSON().count < 5;

getAction

To fetch the result of any action that ran before this action, use getAction()

Syntax:

getAction('action_name').result.stdout.JSON().count < 5;

Context

Templates receive a context variable that contain details about the config or component it is running for. In addition, it also contains the optional params variable which contains the parameters passed to the playbook.

FieldDescriptionSchema
.configConfig passed to the playbookConfigItem
.componentComponent passed to the playbookComponent
.checkCanary Check passed to the playbookCheck
.paramsUser provided parameters to the playbookmap[string]string
.user.nameName of the user who invoked the actionstring
.user.emailEmail of the user who invoked the actionstring