Giter VIP home page Giter VIP logo

puppet-sonarqube's Introduction

puppet-sonarqube

Build Status Puppet Forge Puppet Forge

Table of Contents

  1. Overview
  2. Usage
  3. Reference
  4. Development
  5. License

Overview

A puppet module to install and configure SonarQube (former Sonar).

The main goal is compatibility with the latest LTS release of SonarQube. Older versions are not supported. However, newer versions should usually work too.

Usage

Basic usage

The minimum configuration should at least specify the desired version:

class { 'java': }
class { 'sonarqube':
  version => '8.9.9.56886',
}

NOTE: The $version parameter expects a 4 digit version number (1.2.3.4), which can be found on the SonarQube download page (hidden in the filename).

A more complex example could look like this:

class { 'java': }
class { 'sonarqube':
  version       => '8.9.9.56886',
  edition       => 'community',
  user          => 'sonar',
  group         => 'sonar',
  service       => 'sonar',
  installroot   => '/opt/sonar-install',
  home          => '/opt/sonar-data',
  log_folder    => '/var/log/sonar',
  download_url  => 'https://binaries.sonarsource.com/Distribution/sonarqube',
  jdbc          => {
    url         => 'jdbc:h2:tcp://localhost:9092/sonar',
    username    => 'sonar',
    password    => 'secretpassword',
  },
  web_java_opts => '-Xmx1024m',
  updatecenter  => 'true',
  http_proxy        => {
    host            => 'proxy.example.com',
    port            => '8080',
    ntlm_domain     => '',
    user            => '',
    password        => '',
    non_proxy_hosts => 'localhost|127.*|[::1]',
  },
  sso             => {
    enable        => 'true',
    emailheader   => 'X-Forwarded-Email',
    groupsheader  => 'X-Forwarded-Groups',
    loginheader   => 'X-Forwarded-Login',
    nameheader    => 'X-Forwarded-Name',
    refreshintervalinminutes => '5',
  }
}

SonarQube Plugins

The sonarqube::plugin defined type can be used to install SonarQube plugins. Plugins are available from many different sources, so this module supports multiple download sources as well. It will also purge old plugin versions.

A plugin can be removed by setting the parameter ensure to absent.

Probably the best source for plugins is SonarSource. To download and install one of these plugins, use the following example:

sonarqube::plugin { 'sonar-kotlin-plugin':
  version => '1.7.0.883',
}

Be sure to use the full version number as demonstrated in this example. Check https://binaries.sonarsource.com/Distribution/ and https://docs.sonarqube.org/latest/analysis/languages/overview/ for a list of available plugins.

If the plugin is hosted on GitHub, then you only need to provide a GitHub identifier, which is essentially a combination of the GitHub username and project name:

sonarqube::plugin { 'checkstyle-sonar-plugin':
  version => '4.31',
  ghid    => 'checkstyle/sonar-checkstyle',
}

Note that the GitHub project must provide jar files for its releases. Otherwise the download is prone to fail.

If none of these methods work, you may also specify a direct download URL, which should be seen as a last resort:

sonarqube::plugin { 'sonar-detekt':
  version => '2.0.0',
  url     => 'https://github.com/detekt/sonar-kotlin/releases/download/sonar-detekt-2.0.0.jar',
}

Note that in this case the filename must exactly match the plugin name and version, otherwise this will not work.

Finally the old way to install plugins using Maven is still available, but it requires to set the $legacy parameter:

class { 'maven::maven': }

sonarqube::plugin { 'sonar-javascript-plugin':
  legacy  => true,
  groupid => 'org.sonarsource.javascript',
  version => '2.10',
}

The defunct maestrodev/puppet-maven module is required to make this work. And it is most likely not very useful on newer versions of SonarQube and may be removed in future versions of this module. (Please open an issue on GitHub if you think this is still useful.)

LDAP Configuration

The sonarqube class provides an easy way to configure security with LDAP, Crowd or PAM. Here's an example with LDAP:

$ldap = {
  url          => 'ldap://myserver.mycompany.com',
  user_base_dn => 'ou=Users,dc=mycompany,dc=com',
  local_users  => ['foo', 'bar'],
}

class { 'java': }
-> class { 'sonarqube':
  ldap    => $ldap,
  version => '8.9.9.56886'
}

# Do not forget to add the SonarQube LDAP plugin that is not provided out of
# the box on SonarQube versions older than 8.0. Same thing with Crowd or PAM.
sonarqube::plugin { 'sonar-ldap-plugin':
  version => '2.2.0.608',
}

Reference

Classes and parameters are documented in REFERENCE.md.

Development

Contributing

Please use the GitHub issues functionality to report any bugs or requests for new features. Feel free to fork and submit pull requests for potential contributions.

All contributions must pass all existing tests, new features should provide additional unit/acceptance tests.

License

Copyright 2019-2022 markt.de GmbH & Co. KG
Copyright 2011-2013 MaestroDev, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

puppet-sonarqube's People

Contributors

aba-rechsteiner avatar aba-thw avatar alsobrsp avatar andreyev avatar arioch avatar bramwelt avatar brettporter avatar carlossg avatar conor0callaghan avatar dcrissman avatar dpavlotzky avatar f0 avatar fraenki avatar hdep avatar j-gerding avatar jjungnickel avatar kitplummer avatar lclair avatar lightning- avatar marvin0815 avatar nwheeler avatar pierrer avatar pulquero avatar racodond avatar rickard-von-essen avatar sjeandeaux avatar storm49152 avatar talseth avatar thijsdezoete avatar velocity303 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

puppet-sonarqube's Issues

Add support for additionnal sonar config entries

The current sonar.properties.epp template only support a subset of all possible sonar properties. It is for example missing the SAML options.

Adding all the possible options might not be feasible, and not future proof, it might be best to add a additional_config_options hash.

Add ldap.StartTLS parameter

The ldap.StartTLS parameter is currently missing. Adding this parameter would make it possible to secure the ldap connection using TLS.

SonarQube version 9.6 breaks due to incompatible changes

SonarQube version 9.4 and 9.5 work without any issues. Upgrading to 9.6.1.59531 causes the following error:

sonar.service: Can't open PID file /opt/sonar/data/SonarQube.pid (yet?) after start: Operation not permitted

If I manually change the permissions of the file system, I get the following error in the logs

The database must be manually upgraded. Please backup the database and browse /setup

But the web server never loads and /setup cannot be run.

Any ideas what the cause might be? Something different in 9.6?

SonarQube Crowd template, trouble setting realm.

The templates/sonar.properties.epp in the Crowd section it should probably say something like:
sonar.security.realm=Crowd

Also I don't see a way to set sonar.security.localUsers='admin,sonar' either.

Is there a way to add custom lines to the sonar.properties file?

[o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143

I'm using this module into a Ubuntu 18.04 and puppet 6.17.0

This is my code...

  class { 'sonarqube':
    version       => '7.9',
    edition       => 'community',
    user          => 'sonar',
    group         => 'sonar',
    service       => 'sonar',
    installroot   => '/opt/sonar-install',
    home          => '/opt/sonar-data',
    log_folder    => '/var/log/sonar',
    download_url  => 'https://binaries.sonarsource.com/Distribution/sonarqube',
    jdbc          => {
      url         => "jdbc:mysql://${sonar_db_host}:3306/${sonar}?useUnicode=true&characterEncoding=utf8",
      username    => $sonar_db_user,
      password    => $sonar_db_pass,
    },  
    web_java_opts => '-Xmx1024m',
    updatecenter  => true
  }

This is the puppet output...

Notice: /Stage[main]/Sonarqube::Service/File_line[set PIDDIR in startup script]/ensure: created (corrective)
Notice: /Stage[main]/Sonarqube::Service/File_line[set RUN_AS_USER in startup script]/ensure: created (corrective)
Error: Could not enable sonar: 
Error: /Stage[main]/Sonarqube::Service/Service[sonarqube]/ensure: change from 'stopped' to 'running' failed: Could not enable sonar: 
Notice: /Stage[main]/Sonarqube::Service/Service[sonarqube]: Triggered 'refresh' from 1 event
Info: Class[Sonarqube::Service]: Unscheduling all events on Class[Sonarqube::Service]
Info: Stage[main]: Unscheduling all events on Stage[main]
Notice: Applied catalog in 28.60 seconds

This is the sonar log...

--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

15:17:40.440 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'rewriteBatchedStatements=true'
15:17:40.444 [WrapperSimpleAppMain] WARN org.sonar.application.config.JdbcSettings - JDBC URL is recommended to have the property 'useConfigs=maxPerformance'
2020.09.11 15:17:40 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonar-install/sonarqube-7.9/temp
2020.09.11 15:17:40 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2020.09.11 15:17:40 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonar-install/sonarqube-7.9/elasticsearch]: /opt/sonar-install/sonarqube-7.9/elasticsearch/bin/elasticsearch
2020.09.11 15:17:40 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
2020.09.11 15:17:41 INFO  app[][o.e.p.PluginsService] no modules loaded
2020.09.11 15:17:41 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2020.09.11 15:17:53 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2020.09.11 15:17:53 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonar-install/sonarqube-7.9]: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonar-install/sonarqube-7.9/temp --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Xmx1024m -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/common/*:/opt/sonar-install/sonarqube-7.9/lib/jdbc/mysql/mysql-connector-java-5.1.46.jar org.sonar.server.app.WebServer /opt/sonar-install/sonarqube-7.9/temp/sq-process9108603129757050528properties
2020.09.11 15:17:57 INFO  app[][o.s.a.SchedulerImpl] Process[web] is stopped
2020.09.11 15:17:57 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143
2020.09.11 15:17:57 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2020.09.11 15:17:57 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped

By the way, the log is in /opt/sonar-data/logs/sonar.log nor in log_folder => '/var/log/sonar'

Service enable fails

Hi,

just tried the module on debian 10 (buster) to install sonarqube but i'm getting the following error:

==> default: Running provisioner: puppet...
==> default: Running Puppet with environment production...
==> default: Notice: Compiled catalog for sonarqube1.vagrant.local in environment production in 3.71 seconds
==> default: Error: Could not enable sonar: 
==> default: Error: /Stage[main]/Sonarqube::Service/Service[sonarqube]/enable: change from 'false' to 'true' failed: Could not enable sonar: 
==> default: Notice: Applied catalog in 3.73 seconds
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

After changing https://github.com/markt-de/puppet-sonarqube/blob/master/manifests/service.pp#L28 to absent it worked as it should.

It looks like that at least debian does not like if there is an init.d-script and a systemd unit with the same name. As the module officially only supports distributions with systemd i would open an PR to absent the init.d-script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.