1.8 KiB
1.8 KiB
title, description, weight
| title | description | weight |
|---|---|---|
| Action development | Developing atomic automation tasks in the Root framework. | 30 |
Actions are atomic automation tasks. Following the "Stupid Action" philosophy, they must remain declarative and rely on the library for complex operations.
Creating a new action
{{% steps %}}
Step 1: Create the script file
Place your script in scripts/actions/{group}/{name}. Do not use file extensions.
Step 2: Implement metadata
Every action must provide a description and argument list for the help system.
action_metadata() {
cat <<EOF
description: "Brief summary of the task."
args:
- NODE: "The node name"
- PARAM: "A custom parameter"
EOF
}
Step 3: Initialize context
Use the root_require_node helper to establish the environment. This must be the first functional step in your script.
root_require_node "${1:-}"
shift
Step 4: Use namespaced helpers
Perform operations using the root_* library functions. Rely on ROOT_ environment variables for all pathing.
root_log_info "Processing node $ROOT_NODE"
root_sys_restart_service "my-service"
{{% /steps %}}
Library namespaces
Actions have access to the following modules:
root_core_*: Logging and Telegram notifications.root_init_*: Declarative service initialization and package management.root_sys_*: Systemd and unit file management.root_template_*: Envsubst-based rendering and configuration injection.root_validate_*: Input, file, and OS validation.
See also: