Skip to content

Playbooks

A playbook is a script that can be attached as a rule action to execute a certain task. Currently, a playbook is written in python programming language.

image not found

Which programming languages are supported for playbook script?

Currently, python is the only supported language for scripting.

Where do the playbooks run?

The playbooks are designed to run on customers's datacenter that reach out to the Avalanchio services for data communication over a secured HTTPs protocol. Before you run the playbook, you need to setup an agent. The avalanchio agent is a small light weight python script that keeps sending a long poll request to Avalanchio server for any new tasks that need to be executed in the playbook environment. During the development time, you can run the agent on the your laptop.

During production, setup the agent to run the background daemon process described in the later section. When a playbook needs to run, the agent received a task execution request, it pull the task from server and executes it in the agent's current environment.

The agent requires only python3.8+ without any external libraries but the the playbook script may require additional packages depending on which libraries developers would have used in the script, for example pandas, numpy etc.

User permissions for agent

Run the agent as standard operating system user (without sudo permissions). Create a virtual environment for agent so that it runs in an isolated python environment.

Structure of playbook script?

For every script, the entry point is "process" method. User can take any kind of input from any service in the process method. You can specify the input parameters, in the params tab.

Example:

import sys

def process(*args, **kwargs):
    print("Hello agent: ", sys.executable)
    return 

Test Playbook

To test the playbook, first setup an agent with the current user's token.

User can specify the argument name in the definition or "args" "*kwargs" would work as same. User needs to specify the input in the test script Input json screen in json format.It can be tested by executing the script Example:

def process(*args, **kwargs):
{"name":"shreyasi"}