SonarQube role
Deploy SonarQube Community Edition, a code quality and security analysis platform, with PostgreSQL database backend.
Usage
Configure SonarQube database credentials in your inventory:
1 2 3 4 5 | |
Include the role in your playbook:
1 2 3 4 | |
The role provides these tags:
- sonarqube-install - Deploy SonarQube with PostgreSQL database
- sonarqube-uninstall - Remove SonarQube containers and volumes
Docs
Deploy SonarQube to your Docker host:
1 | |
Remove SonarQube installation:
1 | |
Configuration Details
The role deploys SonarQube with:
- Official Image: sonarqube:community (latest)
- Database: PostgreSQL (configurable version, default 16-alpine)
- Persistent Storage: Separate volumes for data, extensions, logs, and database
- Network: Uses external caddy_old network for reverse proxy integration
- Auto-pull: Always pulls latest image on deployment
Architecture
The deployment consists of two containers: 1. sonarqube - Main application container 2. sonarqube-db - PostgreSQL database
Both containers are on the caddy_old network for reverse proxy access.
Accessing SonarQube
Configure your reverse proxy (Caddy) to route traffic to the sonarqube container on port 9000.
Default credentials on first access: - Username: admin - Password: admin (you'll be prompted to change this)
Storage
Five volumes are created:
- sonarqube_data - SonarQube application data
- sonarqube_extensions - Installed plugins and extensions
- sonarqube_logs - Application logs
- postgresql - PostgreSQL system files
- postgresql_data - PostgreSQL database data
Database Connection
SonarQube connects to PostgreSQL via JDBC:
- URL: jdbc:postgresql://sonarqube-db:5432/{database_name}
- Username: Configured via sonarqube_pg_unsername
- Password: Configured via sonarqube_pg_password
System Requirements
SonarQube requires:
- At least 2GB of RAM
- System setting: vm.max_map_count >= 524288
- System setting: fs.file-max >= 131072
Configure these on the host if needed:
1 2 | |
Integration
After deployment, integrate SonarQube with your CI/CD pipeline: 1. Create a project in SonarQube web UI 2. Generate an authentication token 3. Configure your build tool (Maven, Gradle, etc.) with SonarQube scanner 4. Add analysis to your build pipeline
