lean_delivery.sonarqube
SonarQube Role
This role installs SonarQube along with many additional plugins. The example playbook provided uses openJDK, a PostgreSQL database, and an nginx web server with HTTPS enabled.
For more details, check this article: How to add SonarQube to CI process.
Besides the default plugins, the SonarQube role can also install the following recommended plugins:
- checkstyle-sonar-plugin
- sonar-pmd-plugin
- sonar-findbugs-plugin
- mutation-analysis-plugin
- and several more...
Optional plugins are also available, but be careful as some might not work with the latest versions of SonarQube. To see the full list of compatible plugins, refer to the plugin matrix.
This role comes with various configuration options, such as:
- Migrating the database when updating SonarQube to a new version
- Setting up a Jenkins webhook
- Restoring custom profiles
- LDAP configuration
- Changing the admin user password
For a sample Jenkins pipeline, see: Example Jenkins Pipeline.
Requirements
- Ansible Versions Supported:
- 5 (2.12) - not extensively tested yet, should work
- 6 (2.13)
- 7 (2.14)
- SonarQube Versions Supported:
- 7.9.6 previous LTS
- 8.9.10 previous LTS
- 9.9.6 LTS
- 10.0 - 10.6
- Java Versions Supported:
- 11
- 17 (for SonarQube 9.9+)
- Databases Supported:
- PostgreSQL
- MySQL (not recommended)
- Embedded H2 (for testing only)
- Web Servers Supported (for HTTPS):
- nginx
- Operating Systems Supported:
- CentOS, RHEL (7)
- Ubuntu (18.04, 20.04 and 22.04 should work, but are not tested yet)
Make sure to install Java, the database, and a web server with a self-signed certificate before running this role. Use the following Ansible Galaxy roles:
- lean_delivery.java
- geerlingguy.postgresql
- jdauphant.ssl-certs
- nginxinc.nginx
Role Variables
sonar_version
: Version of SonarQubesonar_path
: Installation directory (default: /opt/sonarqube)sonar_user
: User for installing SonarQube (default: sonar)sonar_group
: Group of SonarQube user (default: sonar)sonar_nofile
: Maximum number of open file descriptors (default: 65536)sonar_nproc
: Maximum number of threads (default: 4096)sonar_max_map_count
: Limit for Elasticsearch mmap counts (default: 262144)sonar_log_level
: Logging level (default: INFO)- Various options for configuring web server, database, plugins, and more.
Example Playbook
---
- name: Install SonarQube
hosts: sonarqube
become: true
vars:
# java
java_major_version: 17
transport: repositories
# postgresql
postgresql_users:
- name: sonar
password: sonar
postgresql_databases:
- name: sonar
# sonarqube
sonar_version: 10.6.0
sonar_check_url: 'http://{{ ansible_fqdn }}:9000'
sonar_web_password: your_new_secure_password
change_password: true
sonar_web_old_password: admin
pre_tasks:
- name: delete previous SonarQube installation
file:
path: '{{ sonar_path }}'
state: absent
roles:
- role: lean_delivery.java
- role: geerlingguy.postgresql
- role: nginxinc.nginx
- lean_delivery.sonarqube
tasks:
- name: remove default nginx config
file:
path: /etc/nginx/conf.d/default.conf
state: absent
- name: reload nginx
command: 'nginx -s reload'
License
Apache
Author Information
authors:
- Lean Delivery Team team@lean-delivery.com
Lean Delivery SonarQube server install
ansible-galaxy install lean_delivery.sonarqube