Skip to content

Commit f24f7fb

Browse files
author
Jarkko Oranen
committed
Use a common EPP template for dbconfig
This removes the use_connection_pooling parameter since for most databases, it does nothing anyway, and with PostgreSQL it should always be enabled.
1 parent 1c183ee commit f24f7fb

8 files changed

Lines changed: 66 additions & 146 deletions

manifests/config.pp

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,40 @@
1919
group => $jira::group,
2020
}
2121

22-
if $jira::validation_query == undef {
23-
$validation_query = $jira::db ? {
24-
'postgresql' => 'select version();',
25-
'mysql' => 'select 1',
26-
'oracle' => 'select 1 from dual',
27-
'sqlserver' => 'select 1',
28-
'h2' => 'select 1',
29-
}
22+
$dbschema_default = $jira::db ? {
23+
'postgresql' => 'public',
24+
default => undef
3025
}
31-
if $jira::time_between_eviction_runs == undef {
32-
$time_between_eviction_runs = $jira::db ? {
33-
'postgresql' => '30000',
34-
'mysql' => '300000',
35-
'oracle' => '300000',
36-
'sqlserver' => '300000',
37-
'h2' => '5000',
38-
}
26+
27+
$dbschema = if $jira::dbschema { $jira::dbschema } else { $dbschema_default }
28+
29+
$validation_query_default = $jira::db ? {
30+
'postgresql' => 'select version();',
31+
'mysql' => 'select 1',
32+
'oracle' => 'select 1 from dual',
33+
'sqlserver' => 'select 1',
34+
'h2' => 'select 1',
3935
}
4036

37+
$validation_query = if $jira::validation_query { $jira::validation_query } else { $validation_query_default }
38+
39+
$time_between_eviction_runs_default = $jira::db ? {
40+
'postgresql' => '30000',
41+
'mysql' => '300000',
42+
'oracle' => '300000',
43+
'sqlserver' => '300000',
44+
'h2' => '5000',
45+
}
46+
47+
$time_between_eviction_runs = if $jira::time_between_eviction_runs { $jira::time_between_eviction_runs } else { $time_between_eviction_runs_default }
48+
49+
$validation_query_timeout_default = $jira::db ? {
50+
'mysql' => 3,
51+
default => undef,
52+
}
53+
54+
$validation_query_timeout = if $jira::validation_query_timeout { $jira::validation_query_timeout } else { $validation_query_timeout_default }
55+
4156
file { "${jira::webappdir}/bin/user.sh":
4257
content => template('jira/user.sh.erb'),
4358
mode => '0755',
@@ -56,7 +71,7 @@
5671
}
5772

5873
-> file { "${jira::homedir}/dbconfig.xml":
59-
content => template("jira/dbconfig.${jira::db}.xml.erb"),
74+
content => epp("jira/dbconfig.xml.epp"),
6075
mode => '0600',
6176
require => [Class['jira::install'],File[$jira::homedir]],
6277
notify => Class['jira::service'],

manifests/init.pp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,19 @@
6363
Optional[String] $dbtype = undef,
6464
Optional[String] $dburl = undef,
6565
$poolsize = '20',
66-
$dbschema = 'public',
66+
$dbschema = undef,
6767
# MySQL Connector Settings
6868
$mysql_connector_manage = true,
6969
$mysql_connector_version = '5.1.34',
7070
$mysql_connector_product = 'mysql-connector-java',
7171
$mysql_connector_format = 'tar.gz',
7272
Stdlib::Absolutepath $mysql_connector_install = '/opt/MySQL-connector',
7373
Stdlib::HTTPUrl $mysql_connector_url = 'https://dev.mysql.com/get/Downloads/Connector-J',
74-
# Configure database settings if you are pooling connections
75-
$enable_connection_pooling = false,
7674
$pool_min_size = 20,
7775
$pool_max_size = 20,
7876
$pool_max_wait = 30000,
7977
$validation_query = undef,
78+
Optional[Integer] $validation_query_timeout = undef,
8079
$min_evictable_idle_time = 60000,
8180
$time_between_eviction_runs = undef,
8281
$pool_max_idle = 20,

templates/dbconfig.h2.xml.erb

Lines changed: 0 additions & 23 deletions
This file was deleted.

templates/dbconfig.mysql.xml.erb

Lines changed: 0 additions & 26 deletions
This file was deleted.

templates/dbconfig.oracle.xml.erb

Lines changed: 0 additions & 24 deletions
This file was deleted.

templates/dbconfig.postgresql.xml.erb

Lines changed: 0 additions & 28 deletions
This file was deleted.

templates/dbconfig.sqlserver.xml.erb

Lines changed: 0 additions & 25 deletions
This file was deleted.

templates/dbconfig.xml.epp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<%# Some default are set in jira::config based on DB -%>
4+
<jira-database-config>
5+
<name>defaultDS</name>
6+
<delegator-name>default</delegator-name>
7+
<database-type><%= $jira::dbtype_real %></database-type>
8+
<% if $jira::config::dbschema { -%>
9+
<schema-name><%= $jira::config::dbschema %></schema-name>
10+
<% } -%>
11+
<jdbc-datasource>
12+
<url><%= $jira::dburl_real %></url>
13+
<driver-class><%= $jira::dbdriver_real %></driver-class>
14+
<username><%= $jira::dbuser %></username>
15+
<password><%= $jira::dbpassword %></password>
16+
<pool-size><%= $jira::poolsize %></pool-size>
17+
<pool-min-size><%= $jira::pool_min_size %></pool-min-size>
18+
<pool-max-size><%= $jira::pool_max_size %></pool-max-size>
19+
<pool-max-wait><%= $jira::pool_max_wait %></pool-max-wait>
20+
<min-evictable-idle-time-millis><%= $jira::min_evictable_idle_time %></min-evictable-idle-time-millis>
21+
<pool-max-idle><%= $jira::pool_max_idle %></pool-max-idle>
22+
<pool-remove-abandoned><%= $jira::pool_remove_abandoned %></pool-remove-abandoned>
23+
<pool-remove-abandoned-timeout><%= $jira::pool_remove_abandoned_timeout %></pool-remove-abandoned-timeout>
24+
<pool-test-while-idle><%= $jira::pool_test_while_idle %></pool-test-while-idle>
25+
<pool-test-on-borrow><%= $jira::pool_test_on_borrow %></pool-test-on-borrow>
26+
<validation-query><%= $jira::config::validation_query %></validation-query>
27+
<% if $jira::config::validation_query_timeout { -%>
28+
<validation-query-timeout><%= $jira::config::validation_query_timeout %></validation-query-timeout>
29+
<% } -%>
30+
<time-between-eviction-runs-millis><%= $jira::config::time_between_eviction_runs %></time-between-eviction-runs-millis>
31+
</jdbc-datasource>
32+
</jira-database-config>

0 commit comments

Comments
 (0)