Action context
3 minute read
Actions are one of the most powerful ways to extend CMP. Besides the action inputs you define, several CMP objects are available as context to any template-enabled action attribute, such as plugin source, a webhook payload, or an email hook body. To see which attributes can be templated for each type, see Action types.
This context is also available outside actions, when custom YAML files provision Kubernetes objects. See Container orchestrators.
Built-in context by use case
Single server action
Run by a user on an existing server.
server: The single Server object, when there is only one.- For remote script actions,
script_usernameandscript_password: Run the script as this user.
Batch server action
Run by a user on one or more existing servers.
- Everything provided by a single server action.
servers: An array of Server objects.
Display condition plugin for a server action
Determines whether the server action is shown.
server: This plugin only ever operates on a single Server object at a time.request: The current request, which can be used to determine the profile of the user trying to view server actions for the server.
Resource action
Run on a deployed resource.
resourceresource attributes: A dictionary of key/value pairs, such as{"azure_website": "http://example.com"}.servers- For a Scale Up resource action,
service_item: The server tier the user selected.
Blueprint action
Run during blueprint deployment.
resource, when the blueprint creates one.servers- For a load balancer blueprint action, the blueprint action keys plus
source_portanddestination_port.
Built-in context for special cases
For the email hook action type, CMP provides a job object. Use it to include a link to the job detail view in the email body:
View the details of this CloudBolt job: https://CB-SERVER-NAME{{ job.get_absolute_url }}
Description of context keys
| Key | Description |
|---|---|
blueprint |
The CMP object for the blueprint associated with this action. |
environment |
The CMP object for the environment associated with this action. |
group |
The CMP object for the group associated with this action. |
job |
The CMP object for the job associated with this action. |
server |
Points at the single server object that applies for the action. If more than one server is being worked on at the same time, use the servers key instead. |
servers |
A list of server objects directly related to the action being run. |
resource |
Points at the resource object that applies for the action. Supports direct parameter reference, such as {{resource.expiration_date}}. |
blueprint_context |
A dictionary of information about the blueprint being deployed. It includes resource_name and a key for each build item in the blueprint, named after the slugified build item name. For more information on the context available for each build item, see Blueprint actions. |