lrk.sonarqube

Ansible Role: SonarQube

This Ansible Role helps you install SonarQube.

Supported Operating Systems

We have tested this role on:

  • EL - 7
  • Debian - Stretch

Requirements

To run SonarQube, you need:

  • Oracle JRE 11 or OpenJDK 11 installed on your machine.

For production, set sonar_db_embedded to false and configure the sonar_db_* variables. SonarQube supports MySQL, Oracle, PostgreSQL, and Microsoft SQLServer.

If you need more details, check the SonarQube requirements.

Installing Plugins

This role allows you to install plugins following the "SonarQube Install a Plugin" guide. You can install from the marketplace or manually.

Note: You must remove old plugin versions yourself.

To install plugins, list them in the sonar_plugins dictionary. Here are some options:

  • name: the name of the plugin (for the marketplace, use the name from here).
  • version: the plugin version.
  • commercial: is this a commercial plugin (applicable for manual plugins only).
  • url: link to the plugin's jar file, only needed for manual plugins.
  • marketplace: indicates whether it’s a manual or marketplace plugin (default is false).

Example:

sonar_plugins:
  - name: "sonar-city-model-plugin"
    version: "3.3"
    commercial: true
    url: "http://example.com/sonar-city-model-plugin-3.3.jar"
  - name: "ansible"
    version: "2.4.0"
    marketplace: true

Testing Locally with Vagrant

  1. Install Vagrant and VirtualBox.
  2. Set up a virtual environment and install requirements:
python -m venv ~/.virtualenvs/molecule
. ~/.virtualenvs/molecule/bin/activate
pip install -r molecule/vagrant/requirements.txt
  1. Run tests (default uses CentOS):
molecule test -s vagrant
  1. (Optional) Test on another OS (like Ubuntu):
MOLECULE_DISTRO=ubuntu/trusty64 molecule test -s vagrant

Role Variables

Here are the available variables and their default values (found in defaults/main.yml):

  • sonar_install_directory: /opt/sonarqube
  • sonar_version: 5.6.7
  • sonar_plugins: []
  • sonar_db_embedded: true (not for production)
  • sonar_jdbc_url: "" (JDBC connection string)
  • sonar_limitnofile: 65536
  • Other configurations related to logging, networking, and databases.

Dependencies

There are no direct dependencies. Just ensure JDK is installed first.

Example Playbook

- hosts: servers
  pre_tasks:
    - name: Install package dependencies.
      package:
        name: "{{ item }}"
        state: "present"
      with_items:
        - unzip
  roles:
    - lrk.sonarqube

Upgrading SonarQube

Always test upgrades in a staging environment first.

Steps to Upgrade:

  1. Update the variable sonar_version.
  2. Review sonar_plugins as per the plugin version matrix.
  3. Run the role again. Ansible will:
    • Create a new installation folder.
    • Place new SonarQube binaries and plugins.
    • Stop the current service.
    • Update configurations.
    • Restart the service.
    • Make sure the web service and version are up and running.
  4. Visit http://yourSonarQubeServerURL/setup and follow these setup instructions.

Important Notes:

  • The role does not back up the database.
  • Please avoid accidentally downgrading.
  • The role does not delete the older installation folder.

License

Apache License Version 2.0

References

Author Information

This role was created by Lrk.

Informazioni sul progetto

An Ansible Role that install SonarQube.

Installa
ansible-galaxy install lrk.sonarqube
Licenza
apache-2.0
Download
103.5k
Proprietario