Referensi API
Pendahuluan
Ansible Service menyediakan API REST bagi Backend Ravenxcope untuk memicu eksekusi playbook dan mengelola file aturan. Semua titik akhir (kecuali health check) berada di bawah awalan /api.
Health Check
Ambil Status Layanan
Mengembalikan kesehatan saat ini dan waktu sistem dari layanan.
- URL:
/health - Metode:
GET - Respons:
{
"status": "healthy",
"service": "ansible-executor",
"time": "2025-12-19T12:00:00Z"
}
Eksekusi Playbook
Eksekusi Pengaturan Sensor (Sensor Setup)
Memulai konfigurasi awal host sensor.
- URL:
/api/playbooks/sensor-setup - Metode:
POST - Body:
{
"uuid": "sensor-uuid",
"interface": "eth0",
"host_ip": "192.168.1.100",
"host_user": "ubuntu",
"host_pass": "password123"
}
- Respons (202 Accepted):
{
"success": true,
"message": "Playbook execution started",
"executionId": "exec-123456789",
"status": "pending"
}
Eksekusi Aktivasi Sensor (Sensor Activation)
Menyebarkan dan mengaktifkan playbook tertentu (misalnya, sensor-activate) pada sensor.
- URL:
/api/playbooks/sensor-activate - Metode:
POST - Body:
{
"playbook": "sensor-activate",
"host": "192.168.1.100",
"port": 22,
"username": "ubuntu",
"password": "password123",
"variables": {
"uuid": "sensor-uuid",
"interface": "eth0",
"backend_url": "http://10.10.10.70:5009"
}
}
Manajemen Eksekusi
Daftar Semua Eksekusi
Mengembalikan daftar semua eksekusi playbook dalam sesi saat ini.
- URL:
/api/executions - Metode:
GET - Respons:
{
"success": true,
"executions": [...],
"total": 5
}
Ambil Status Eksekusi
Mengembalikan informasi detail tentang eksekusi tertentu, termasuk output Ansible lengkap.
- URL:
/api/executions/:id - Metode:
GET - Respons:
{
"id": "exec-123456789",
"uuid": "sensor-uuid",
"status": "completed",
"output": "...",
"startedAt": "2025-12-19T12:00:00Z",
"endedAt": "2025-12-19T12:05:00Z"
}
Manajemen Aturan
Unggah File Aturan
Mengunggah file aturan baru ke repositori pusat.
- URL:
/api/rules/upload - Metode:
POST - Form Data:
file: File aturan yang akan diunggah.type: (Opsional) Tipe aturan (misalnya,suricata).description: (Opsional) Deskripsi aturan.
Daftar File Aturan
Mencantumkan semua file aturan yang tersedia.
- URL:
/api/rules - Metode:
GET
Unduh File Aturan
Mengunduh file aturan tertentu.
- URL:
/api/rules/:filename - Metode:
GET
Hapus File Aturan
Menghapus file aturan dari repositori.
- URL:
/api/rules/:filename - Metode:
DELETE