Gerrit-2.8: Add secondary index support

This rebuilds secondary indexes on gerrit initial-init and init. They
are optional in gerrit 2.8, and mandatory in gerrit 2.9.

A few common strings are refactored into variables to make this more
concise, and less likely to get fat fingered. If desired, further
symbolic refactoring can be done here as well.

Question remains if we need to make this 2.8 conditional, and how we
can get access to the gerrit revision in this part of puppet.

Partial-Bug: #1082781
Change-Id: Iee94934baaa220313a7e888ba0e2a6530eab0d52
This commit is contained in:
David Ostrovsky 2013-12-04 23:26:42 +01:00 committed by Jeremy Stanley
parent 13590a6239
commit aa86bee7f3
2 changed files with 20 additions and 4 deletions

View File

@ -77,6 +77,13 @@
# testmode:
# Set this to true to disable cron jobs and replication,
# which can interfere with testing.
# secondary_index:
# Set this to true to enable secondary index support
# secondary_index_type:
# which secondary index to use: SQL (no secondary index),
# LUCENE (recommended), SOLR (experimental). Note: as of
# Gerrit 2.9 LUCENE is default secondary index and SQL is
# removed.
# TODO: make more gerrit options configurable here
#
class gerrit(
@ -141,7 +148,9 @@ class gerrit(
$gitweb = true,
$cgit = false,
$web_repo_url = '',
$testmode = false
$testmode = false,
$secondary_index = false,
$secondary_index_type = 'LUCENE',
) {
include apache
include jeepyb
@ -151,6 +160,9 @@ class gerrit(
'precise' => '/usr/lib/jvm/java-7-openjdk-amd64/jre',
}
$gerrit_war = '/home/gerrit2/review_site/bin/gerrit.war'
$gerrit_site = '/home/gerrit2/review_site'
user { 'gerrit2':
ensure => present,
comment => 'Gerrit',
@ -509,7 +521,7 @@ class gerrit(
}
# If gerrit.war isn't the same as $basewar, install it.
file { '/home/gerrit2/review_site/bin/gerrit.war':
file { $gerrit_war:
ensure => present,
source => "file:///home/gerrit2/gerrit-wars/${basewar}",
require => Exec["download:${war}"],
@ -525,7 +537,7 @@ class gerrit(
# If gerrit.war was just installed, run the Gerrit "init" command.
exec { 'gerrit-initial-init':
user => 'gerrit2',
command => '/usr/bin/java -jar /home/gerrit2/review_site/bin/gerrit.war init -d /home/gerrit2/review_site --batch --no-auto-start',
command => "/usr/bin/java -jar ${gerrit_war} init -d ${gerrit_site} --batch --no-auto-start; /usr/bin/java -jar ${gerrit_war} reindex -d ${gerrit_site}",
subscribe => File['/home/gerrit2/review_site/bin/gerrit.war'],
refreshonly => true,
require => [Package['openjdk-7-jre-headless'],
@ -543,7 +555,7 @@ class gerrit(
# Running the init script as the gerrit2 user _does_ work.
exec { 'gerrit-init':
user => 'gerrit2',
command => '/etc/init.d/gerrit stop; /usr/bin/java -jar /home/gerrit2/review_site/bin/gerrit.war init -d /home/gerrit2/review_site --batch --no-auto-start',
command => "/etc/init.d/gerrit stop; /usr/bin/java -jar ${gerrit_war} init -d ${gerrit_site} --batch --no-auto-start; /usr/bin/java -jar ${gerrit_war} reindex -d ${gerrit_site}",
subscribe => File['/home/gerrit2/review_site/bin/gerrit.war'],
refreshonly => true,
require => [Package['openjdk-7-jre-headless'],

View File

@ -116,3 +116,7 @@
appsec = <%= contactstore_appsec %>
url = <%= contactstore_url %>
<% end -%>
<% if secondary_index == true -%>
[index]
type = <%= secondary_index_type %>
<% end -%>