Playbooks and Rules
Introduction
The core logic of the Ansible Service resides in its playbooks and the rule files it manages. This document explains the purpose of the primary playbooks and how threat detection rules are organized.
Standard Playbooks
Playbooks are located in the playbooks/ directory. The service dynamically generates inventory files and injects extra variables into these playbooks during execution.
1. sensor-setup.yml
This playbook is used for the initial preparation of a sensor host.
- Main Tasks:
- Installs required system packages (Docker, git, curl).
- Configures host networking.
- Ensures Docker is running and properly configured.
- Sets up the Ravenxcope directory structure on the host.
2. sensor-activate.yml
This playbook deploys and starts the detection engines on an already-setup host.
- Main Tasks:
- Pulls the necessary Docker images (Suricata/Snort).
- Deploys the Sensor Agent container.
- Configures the packet capture interface.
- Injects sensor-specific configuration (UUID, Backend URL).
3. sensor-initial-setup.yml
A combined playbook used for fresh installations that performs both host preparation and initial agent deployment.
Rules Management
The service maintains a repository of detection rules in the rules-default/ directory.
Rule File Types
- Suricata Rules (
.rules): Signatures for the Suricata IDS/IPS engine. - Snort Rules (
.conf/.rules): Configuration and signatures for Snort. - Generic Configs: Standardized configuration templates for detection engines.
Deployment Workflow
- Upload: Rules are uploaded via the
/api/rules/uploadendpoint. - Storage: Files are saved in the
rules-default/folder with metadata. - Distribution: During the
sensor-activateprocess, the backend or ansible service can pull these rules and push them to the sensor hosts.
Execution Logic
When a playbook is triggered:
- Inventory Generation: A temporary
.inifile is created containing the target host IP, SSH credentials, and sudo password. - Variable Injection: Extra variables (e.g.,
sensor_uuid,sensor_interface) are passed using the-eflag. - Execution: The service runs
ansible-playbookas a child process. - Capturing Logs: The standard output (STDOUT) and standard error (STDERR) are captured and stored in the execution record.
- Cleanup: Temporary inventory files are deleted immediately after the process finishes.