Skip to content

Examples

Real-world deployment examples demonstrating fscm capabilities.

Available Examples

Django + Nginx

Full Django deployment with Gunicorn WSGI server and Nginx reverse proxy. Covers packages, virtualenv, systemd services, and configuration.

Frigate NVR

Network Video Recorder with camera network isolation. Uses Docker, iptables firewall rules, and dnsmasq for DHCP.

WireGuard VPN

VPN server setup using the wireguard module. Generates server and peer configurations with proper iptables rules.

PostgreSQL Backup

Database server with automated backups using pgBackRest. Includes systemd timers for scheduling.

Monitoring Stack

Prometheus, Grafana, and Alertmanager deployed as a Docker Compose stack with systemd management.

Running Examples

Each example can be run locally or on a remote host:

# Preview changes (dry-run)
python examples/django_nginx/deploy.py --dry-run

# Deploy locally
sudo python examples/django_nginx/deploy.py

# Deploy to remote host
python examples/django_nginx/deploy.py --remote ubuntu@10.0.0.5 --sudo-password

Example Structure

Each example follows this pattern:

examples/
└── example_name/
    ├── deploy.py        # Main deployment script
    ├── templates/       # Jinja2 configuration templates
    │   └── *.j2
    └── README.md        # Example-specific documentation

Common Patterns

CLI Arguments

All examples support these arguments:

Argument Description
--dry-run Preview changes without applying
--remote USER@HOST Deploy to remote host
--sudo-password Prompt for sudo password

Configuration

Examples use constants at the top of the script:

# Configuration
APP_NAME = "myapp"
APP_DIR = "/opt/myapp"
APP_USER = "www-data"
DOMAIN = "example.com"

Function Organization

def install_packages():
    """Install required system packages."""
    ...

def create_directories():
    """Create application directories."""
    ...

def configure_service():
    """Configure and enable systemd service."""
    ...

def main():
    """Main deployment function."""
    install_packages()
    create_directories()
    configure_service()

Customizing Examples

  1. Copy the example directory
  2. Modify constants at the top
  3. Adjust templates as needed
  4. Run with --dry-run to verify
cp -r examples/django_nginx my_deployment
cd my_deployment
# Edit deploy.py and templates
python deploy.py --dry-run