We are glad to welcome you to our website

In the previous example, you probably noticed how you can access parameters from the key-value store by using the st2kv.

You can also get access to variables from the context of the execution. For example:parameters: user: type: "string" description: "User of this action. A simple execution via the API will only contain the variables user and pack. For example, a task in an action chain is shown below:. Once you have tested it out, you should move it to a dedicated pack.

To reload all actions, use st2ctl reload --register-actionsAction runners have their own built-in parameters. These are inherited by the action, and be over-ridden either in the action metadata, or by passing additional parameters when running the action. This is frequently over-ridden for long-running actions. Adjusts the format of arguments passed to cmd. For a full list of built-in parameters for each runner type, see Action Runners. Parameters of runners can be overridden.

Take the following linux. A list of attributes which can be overriden is included below:Overriding attributes such as type and position are not allowed because overriding them can potentially break the action since the runner will not be able to consume the type of value being passed (e. When the action completes, the token gets revoked. Here is an example of how you can use these environment variables inside a local shell script action.

You should make sure that the script exits with a zero status code on success and non-zero on error. This is important since the exit code is used by StackStorm to determine if the script has finished successfully. You need to create a metadata file which describes the script name, description, entry point, which runner to use and script parameters (if any).

When converting an existing script, you will want to use either the local-shell-script or remote-shell-script runner. Positional arguments are serialized based on the simple rules described below:string, integer, float - Serialized as a string.

For working with objects, you can use a tool such as jq. If no value is provided for a particular positional parameter, StackStorm will pass an empty string "" as a value for that parameter to the script. For example, if a second positional parameter is optional and user provides no value, the script will be called like this:script.

This is particularly important if you expose commands via ChatOps and do not like security related parameters to be manipulated by user input. In the simplest form, a Python action is a module which exposes a class which inherits from st2common. Action and implements a run method. As you can see, user-supplied action parameters are passed to the run method as keyword arguments. If the run method finishes without exceptions, the execution is successful, and the value returned by the method (any value: boolean, string, list, dict, etc.

Raising an exception will report the execution as failed. Another way to specify the status of an execution is returning a tuple with two items: the first item is a boolean indicating status, the second item is the result itself. For example, return False will result in a successful execution with the result being False, and return (False, "Failed. In the example above, if the message parameter passed to the action is working, the action will be considered as succeeded (first flag in the result indicating action status is True).

If another message is passed in, action will be considered as failed (first flag in the result tuple indicating action status is False). For a more complex example, please refer to the actions in the Libcloud pack in StackStorm Exchange. Python actions can store arbitrary configuration in the configuration file which is global to the whole pack.

The configuration is stored in a file named. The configuration file format is YAML. Configuration is automatically parsed and passed to the action class constructor via the config argument. See the pack configuration doc for more details.

All logging inside the action should be performed via the logger which is specific to this action and available via the self. This logger is a standard Python logger from the logging module so all the logger methods work as expected (e.

Action service provides different services to the action via public methods. Right now it supports datastore management methods. This allows actions to utilize the datastore to store arbitrary data between executions. The action service provides the same datastore management methods as the ones available on the sensor service.

You can find more details in the sensor datastore management documentation. There are several predefined actions that come out of the box with StackStorm. These are in the core pack:core. You can execute this command via the CLI using:st2 run core. Execute this command via the CLI with:st2 run core.

Think curl executed from the StackStorm box:st2 run core. Explore packs and actions contributed by StackStorm developers and community in the StackStorm Exchange. Check out tutorials on stackstorm. Install and Configure Reference Deployment Overview System Requirements Ubuntu 18.