Server Guide

The ansible-inspec server provides enterprise-ready features for compliance automation at scale.

Overview

The server (introduced in v0.4.0) transforms ansible-inspec from a CLI tool into a full-featured compliance automation platform with:

  • REST API Server: FastAPI-based async API for programmatic access

  • Flexible Storage: File-based (no database) or PostgreSQL (enterprise features)

  • Enterprise Authentication: Azure AD OAuth2 with RBAC (database mode)

  • VCS Integration: Automatic Git sync for InSpec profiles (database mode)

  • Job Orchestration: Background execution with templates and workflows

  • Monitoring: Prometheus metrics and health checks

Architecture Overview

spinner

Quick Start

Simple Start (File Storage Only)

For quick testing or development without database setup:

Note: This mode uses local /data directory for storage. Database-dependent features (authentication, VCS integration) will be disabled.

Installation

Local Development

Architecture

Storage Modes

The server supports three storage backends:

File Storage (Default)

Uses local filesystem for all data. No database required.

Features:

  • ✅ Job templates and execution history

  • ✅ Profile management

  • ✅ JSON-based storage in /data directory

  • ❌ No authentication/authorization

  • ❌ No VCS integration

  • ❌ No multi-user support

Use cases:

  • Local development

  • Single-user testing

  • CI/CD pipelines

  • Quick demos

Database Storage

Full PostgreSQL backend with enterprise features.

Features:

  • ✅ All file storage features

  • ✅ Azure AD authentication & RBAC

  • ✅ VCS integration with Git

  • ✅ Multi-user collaboration

  • ✅ Audit logging

  • ✅ Scalable performance

Use cases:

  • Production deployments

  • Team collaboration

  • Enterprise environments

Hybrid Storage

Dual-write for migration validation (advanced).

See Database Setup Guide for migration details.

Server Workflows

Job Execution Flow

spinner

Authentication Flow (Database Mode)

spinner

VCS Sync Flow (Database Mode)

spinner

Storage Decision Flow

spinner

Key Features

1. Job Templates

Reusable templates for compliance checks:

2. Workflow Orchestration

Chain multiple compliance checks:

3. Azure AD Authentication

Enterprise SSO with role-based access control:

See Authentication Guide for setup details.

4. VCS Integration

Automatic sync of InSpec profiles from Git repositories:

See VCS Integration Guide for configuration.

5. PostgreSQL Database

Production-ready storage with:

  • Connection pooling

  • Type-safe operations (Prisma ORM)

  • Hybrid mode for migration validation

  • Automatic schema management

See Database Setup Guide for details.

API Endpoints

Health & Info

Job Templates

Jobs

Workflows

VCS

Configuration

Environment Variables

Storage Backends

  • database: PostgreSQL only (production)

  • hybrid: Dual-write to both file and database (migration)

  • file: JSON files only (development)

Monitoring

Prometheus Metrics

Available at /metrics:

Health Checks

Security Considerations

Production Deployment

  1. Use HTTPS: Deploy behind a reverse proxy (nginx, Traefik)

  2. Enable Authentication: Set AUTH__ENABLED=true

  3. Secure Database: Use strong passwords and limit network access

  4. Encrypt Credentials: Always set ENCRYPTION_KEY

  5. Network Isolation: Use firewall rules and VPCs

  6. Regular Updates: Keep dependencies up to date

Authentication

  • Azure AD provides enterprise SSO

  • JWT tokens for API access

  • Role-based access control (admin, user, viewer)

  • Session management with secure cookies

Credential Encryption

All VCS credentials (SSH keys, tokens) are encrypted using Fernet symmetric encryption:

Troubleshooting

Server won't start

Database connection errors

Authentication issues

Job execution failures

Best Practices

  1. Use Docker Compose: Simplifies deployment and dependencies

  2. Enable Monitoring: Set up Prometheus and Grafana

  3. Backup Database: Regular PostgreSQL backups

  4. Use VCS Integration: Auto-sync profiles instead of manual uploads

  5. Implement CI/CD: Automate template creation and updates

  6. Monitor Metrics: Track job success rates and durations

  7. Set Resource Limits: Configure job timeouts and concurrency

  8. Use Workflows: Chain related checks for complex scenarios

Next Steps

Support

  • Documentation: https://github.com/Htunn/ansible-inspec/tree/main/docs

  • Issues: https://github.com/Htunn/ansible-inspec/issues

  • Discussions: https://github.com/Htunn/ansible-inspec/discussions

Last updated