Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Add "data_dir" and "temp_dir" parameters to Sonarqube configuration #82

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ before_install:
- rm -f Gemfile.lock

rvm:
- "2.0.0"
- "2.3.1"

env:
- PUPPET_VERSION="~> 3.7.0"
- PUPPET_VERSION="~> 3.6.0"
- PUPPET_VERSION="~> 3.5.0"
- PUPPET_VERSION="~> 3.4.0"
- PUPPET_VERSION="~> 3.3.0"
- PUPPET_VERSION="~> 3.2.0"

matrix:
exclude:
Expand All @@ -38,6 +36,10 @@ matrix:
env: PUPPET_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.4.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_VERSION="~> 3.3.0"

deploy:
provider: puppetforge
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ gem 'simplecov', :require => false
gem 'puppet-blacksmith', '>= 3.3.1', :require => false
gem 'librarian-puppet', '>= 2.0.0', :require => false
gem 'beaker-rspec', '>= 3.0.0', :require => false
gem 'safe_yaml', '~> 1.0.4'

# vim:ft=ruby
71 changes: 66 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
$service = 'sonar',
$installroot = '/usr/local',
$home = undef,
$data_dir = undef,
$temp_dir = undef,
$host = undef,
$port = 9000,
$portAjp = -1,
$portajp = -1,
$download_url = 'https://sonarsource.bintray.com/Distribution/sonarqube',
$download_dir = '/usr/local/src',
$context_path = '/',
Expand All @@ -42,15 +44,20 @@
min_evictable_idle_time_millis => '600000',
time_between_eviction_runs_millis => '30000',
},
$log_folder = '/var/local/sonar/logs',
$log_folder = undef,
$updatecenter = true,
$updatecenter_url = 'http://update.sonarsource.org/update-center.properties',
$http_proxy = {},
$profile = false,
$web_java_opts = undef,
$search_java_opts = undef,
$search_host = '127.0.0.1',
$search_port = '9001',
$config = undef,
$path = {
data_dir => undef,
temp_dir => undef,
},
) inherits sonarqube::params {
validate_absolute_path($download_dir)
Exec {
Expand All @@ -71,6 +78,19 @@
} else {
$real_home = '/var/local/sonar'
}

if $path[data_dir] != undef {
$real_data_dir = $path[data_dir]
} else {
$real_data_dir = "${real_home}/data"
}

if $log_folder != undef {
$real_log_folder = $log_folder
} else {
$real_log_folder = '/var/local/sonar/logs'
}

Sonarqube::Move_to_home {
home => $real_home,
}
Expand Down Expand Up @@ -125,8 +145,48 @@
target => "${installroot}/${package_name}-${version}",
notify => Service['sonarqube'],
}
->
sonarqube::move_to_home { 'data': }
if $path[data_dir] != undef {
exec { 'create_data_dir':
command => "mkdir -p ${real_data_dir}",
creates => $real_data_dir,
require => File[$real_home],
}
->
file { $real_data_dir:
ensure => directory,
owner => $user,
group => $group,
}
}
if $path[temp_dir] != undef {
exec { 'create_temp_dir':
command => "mkdir -p ${path[temp_dir]}",
creates => $path[temp_dir],
require => File[$real_home],
}
->
file { $path[temp_dir]:
ensure => directory,
owner => $user,
group => $group,
}
}
if $log_folder != undef {
exec { 'create_log_folder':
command => "mkdir -p ${real_log_folder}",
creates => $real_log_folder,
require => File[$real_home],
}
->
file { $real_log_folder:
ensure => directory,
owner => $user,
group => $group,
}
}
sonarqube::move_to_home { 'data':
require => File[$real_home],
}
->
sonarqube::move_to_home { 'extras': }
->
Expand All @@ -136,7 +196,8 @@
->
# ===== Install SonarQube =====
exec { 'untar':
command => "unzip -o ${tmpzip} -d ${installroot} && chown -R ${user}:${group} ${installroot}/${package_name}-${version} && chown -R ${user}:${group} ${real_home}",
command => "unzip -o ${tmpzip} -d ${installroot} && chown -R \
${user}:${group} ${installroot}/${package_name}-${version} && chown -R ${user}:${group} ${real_home}",
creates => "${installroot}/${package_name}-${version}/bin",
notify => Service['sonarqube'],
}
Expand Down
8 changes: 4 additions & 4 deletions templates/logback.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<!-- SONAR_STANDALONE/ -->
<!-- do not edit/remove the previous comment -->
<appender name="SONAR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File><%= @log_folder %>/sonar.log</File>
<File><%= @real_log_folder %>/sonar.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<param name="FileNamePattern" value="<%= @log_folder %>/sonar.%i.log"/>
<param name="FileNamePattern" value="<%= @real_log_folder %>/sonar.%i.log"/>
<param name="MinIndex" value="1"/>
<param name="MaxIndex" value="3"/>
</rollingPolicy>
Expand All @@ -48,9 +48,9 @@
<!-- appender used to profile Sonar Server -->
<%= "<!--" if !@profile %>
<appender name="PROFILING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File><%= @log_folder %>/profiling.log</File>
<File><%= @real_log_folder %>/profiling.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<param name="FileNamePattern" value="<%= @log_folder %>/profiling.%i.log"/>
<param name="FileNamePattern" value="<%= @real_log_folder %>/profiling.%i.log"/>
<param name="MinIndex" value="1"/>
<param name="MaxIndex" value="3"/>
</rollingPolicy>
Expand Down
16 changes: 15 additions & 1 deletion templates/sonar.properties.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sonar.web.host: <%= @host %>
#sonar.web.host: 0.0.0.0
<% end -%>
sonar.web.port: <%= @port %>
sonar.ajp.port: <%= @portAjp %>
sonar.ajp.port: <%= @portajp %>
<% if has_variable?('context_path') -%>
sonar.web.context: <%= @context_path %>
<% end -%>
Expand Down Expand Up @@ -204,13 +204,27 @@ sonar.jdbc.timeBetweenEvictionRunsMillis: <% if @jdbc['time_between_eviction_ru

<% end -%>

#---------------------------------------------------------
# DATA FILES PROPERTIES
#---------------------------------------------------------

# Paths to persistent data files (embedded database and search index) and temporary files.
# Can be absolute or relative to installation directory.
# Defaults are respectively <installation home>/data and <installation home>/temp

<% if [email protected]? -%>
<% if @path['data_dir'] %><%= "sonar.path.data: #{@path['data_dir']}" %><% end %>
<% if @path['temp_dir'] %><%= "sonar.path.temp: #{@path['temp_dir']}" %><% end %>
<% end %>

#---------------------------------------------------------
# UPDATE CENTER
#---------------------------------------------------------

# The Update Center requires an internet connection to request http://update.sonarsource.org
# It is activated by default:
sonar.updatecenter.activate=<%= @updatecenter %>
sonar.updatecenter.url=<%= @updatecenter_url %>

<% if !@http_proxy.empty? -%>
# HTTP proxy (default none)
Expand Down