This Ansible playbook automates the installation and configuration of synapse, replicating the functionality of install.sh.
The playbook is modularized into roles:
roles/synapse/- Handles synapse installation and configurationroles/fail2ban/- Optional Fail2Ban integration with Gen0Sec API
Each role can be used independently or together via the main playbook.
- Ansible 2.9 or later
- SSH access to target hosts with sudo privileges
-
Set up inventory file:
cp hosts.example hosts # Edit hosts and add your server details -
Configure variables:
mkdir -p group_vars cp group_vars/all.example.yml group_vars/all.yml # Edit group_vars/all.yml and set your API key -
Run the playbook:
ansible-playbook playbook.yml
Or pass the API token directly:
ansible-playbook playbook.yml -e gen0sec_api_key=your_key_here
- Installs dependencies (curl, sed)
- Optionally installs and configures ClamAV with systemd overrides
- Optionally installs Redis
- Installs synapse using .deb/.rpm packages with binary fallback
- Sets up systemd service and directories
- Downloads and configures config.yaml and upstreams.yaml (binary installation only)
- Supports both Debian/Ubuntu and RedHat/CentOS/Fedora systems
- Enables the synapse service (does not start automatically)
- Optional Fail2Ban integration with Gen0Sec API
synapse_version: Version of synapse to install (default:0.3.3)synapse_branch: GitHub branch for configuration files (default:main)gen0sec_api_key: Gen0Sec API key (used for both synapse and fail2ban, optional, can be set later)clamav_enabled: Enable ClamAV installation and configuration (default:true)redis_enabled: Enable Redis installation (default:true)
fail2ban_enabled: Enable Fail2Ban integration (default:false)gen0sec_expiration: Block expiration time in seconds (default:600= 10 minutes)fail2ban_jail_enabled: Enable fail2ban jails (default:true)fail2ban_backend: Fail2Ban backend (default:systemd)
To enable Fail2Ban integration, set fail2ban_enabled: true in your group_vars/all.yml or pass it via command line:
ansible-playbook playbook.yml -e fail2ban_enabled=trueThe Fail2Ban integration will:
- Install fail2ban and jq
- Download and configure the Gen0Sec action file
- Configure jail.local with Gen0Sec integration
- Enable and start the fail2ban service
The playbook automatically:
- Detects the target system's package manager (apt, dnf, or yum)
- Attempts to install using
.debpackage (Debian/Ubuntu) or.rpmpackage (RHEL/CentOS/Fedora) - Falls back to binary installation if packages are not available
After running the playbook:
- Verify the API key is set in
/etc/synapse/config.yaml - Start the service:
systemctl start synapse - Check status:
systemctl status synapse
You can get your API key from https://dash.gen0sec.com/settings/api-keys