124 lines
2.6 KiB
Markdown
124 lines
2.6 KiB
Markdown
# SAL Runner
|
|
|
|
System Abstraction Layer runner for system-level operations.
|
|
|
|
## Overview
|
|
|
|
The SAL runner executes Rhai scripts with access to system abstraction modules for OS operations, infrastructure management, and cloud provider interactions.
|
|
|
|
## Features
|
|
|
|
- **Rhai Scripting**: Execute Rhai scripts with SAL modules
|
|
- **System Operations**: File, process, and network management
|
|
- **Infrastructure**: Kubernetes, VM, and container operations
|
|
- **Cloud Providers**: Hetzner and other cloud integrations
|
|
- **Database Access**: Redis and Postgres client operations
|
|
- **Networking**: Mycelium and network configuration
|
|
|
|
## Available SAL Modules
|
|
|
|
### Core Modules
|
|
- **sal-os**: Operating system operations
|
|
- **sal-process**: Process management
|
|
- **sal-text**: Text processing utilities
|
|
- **sal-net**: Network operations
|
|
|
|
### Infrastructure
|
|
- **sal-virt**: Virtualization management
|
|
- **sal-kubernetes**: Kubernetes cluster operations
|
|
- **sal-zinit-client**: Zinit process manager
|
|
|
|
### Storage & Data
|
|
- **sal-redisclient**: Redis operations
|
|
- **sal-postgresclient**: PostgreSQL operations
|
|
- **sal-vault**: Secret management
|
|
|
|
### Networking
|
|
- **sal-mycelium**: Mycelium network integration
|
|
|
|
### Cloud Providers
|
|
- **sal-hetzner**: Hetzner cloud operations
|
|
|
|
### Version Control
|
|
- **sal-git**: Git repository operations
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
# Start the runner
|
|
runner_sal my-sal-runner
|
|
|
|
# With custom Redis
|
|
runner_sal my-sal-runner --redis-url redis://custom:6379
|
|
```
|
|
|
|
## Job Payload
|
|
|
|
The payload should contain a Rhai script using SAL modules:
|
|
|
|
```rhai
|
|
// Example: List files
|
|
let files = os.list_dir("/tmp");
|
|
print(files);
|
|
|
|
// Example: Process management
|
|
let pid = process.spawn("ls", ["-la"]);
|
|
let output = process.wait(pid);
|
|
print(output);
|
|
```
|
|
|
|
## Examples
|
|
|
|
### File Operations
|
|
```rhai
|
|
// Read file
|
|
let content = os.read_file("/path/to/file");
|
|
print(content);
|
|
|
|
// Write file
|
|
os.write_file("/path/to/output", "Hello World");
|
|
```
|
|
|
|
### Kubernetes Operations
|
|
```rhai
|
|
// List pods
|
|
let pods = k8s.list_pods("default");
|
|
for pod in pods {
|
|
print(pod.name);
|
|
}
|
|
```
|
|
|
|
### Redis Operations
|
|
```rhai
|
|
// Set value
|
|
redis.set("key", "value");
|
|
|
|
// Get value
|
|
let val = redis.get("key");
|
|
print(val);
|
|
```
|
|
|
|
### Git Operations
|
|
```rhai
|
|
// Clone repository
|
|
git.clone("https://github.com/user/repo", "/tmp/repo");
|
|
|
|
// Get status
|
|
let status = git.status("/tmp/repo");
|
|
print(status);
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Redis server accessible
|
|
- System permissions for requested operations
|
|
- Valid job signatures
|
|
- SAL modules available in runtime
|
|
|
|
## Security Considerations
|
|
|
|
- SAL operations have system-level access
|
|
- Jobs must be from trusted sources
|
|
- Signature verification is mandatory
|
|
- Limit runner permissions in production
|