Skip to content

Commit

Permalink
Add support for Oracle service names
Browse files Browse the repository at this point in the history
Adds $oracle_use_sid, that if set to false modified the JDBC
URL syntax to connect to an Oracle database via a service name.

Also, tests.

Fixes #283

Co-authored-by: negast <[email protected]>
  • Loading branch information
oranenj and negast committed Apr 16, 2021
1 parent 1819d66 commit 9652ac4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ The default value is 'public' for PostgreSQL, and undef for others
This parameter is not required nor do we recommend setting it. However it can be
used to customize the database connection string.

##### `$oracle_use_sid`

Controls whether the module will use SID or service name syntax for the database URL.
Only has an effect if `$dbtype` is oracle. Defaults to true

##### `$pool_max_size`

Setting most of the advanced JDBC parameters is not required unless you want to tune JIRA
Expand Down
4 changes: 3 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@
$dburl_real = $jira::dburl
}
else {
# SIDs use :, service names use /
$oracle_separator = bool2str($jira::oracle_use_sid, ':', '/')
$dburl_real = $jira::db ? {
'postgresql' => "jdbc:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}",
'mysql' => "jdbc:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB",
'oracle' => "jdbc:${jira::db}:thin:@${jira::dbserver}:${dbport_real}:${jira::dbname}",
'oracle' => "jdbc:${jira::db}:thin:@${jira::dbserver}:${dbport_real}${oracle_separator}${jira::dbname}",
'sqlserver' => "jdbc:jtds:${jira::db}://${jira::dbserver}:${dbport_real}/${jira::dbname}",
'h2' => "jdbc:h2:file:/${jira::homedir}/database/${jira::dbname}",
}
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
Optional[String] $dbtype = undef,
Optional[String] $dburl = undef,
Optional[String] $connection_settings = undef,
Boolean $oracle_use_sid = true,
$dbschema = undef,
# MySQL Connector Settings
$mysql_connector_manage = true,
Expand Down
37 changes: 37 additions & 0 deletions spec/classes/jira_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@
end
end

context 'oracle params' do
let(:params) do
{
version: '8.13.5',
javahome: '/opt/java',
db: 'oracle',
dbname: 'mydatabase',
}
end

it do
is_expected.to contain_file('/home/jira/dbconfig.xml').
with_content(%r{jdbc:oracle:thin:@localhost:1521:mydatabase}).
with_content(%r{<database-type>oracle10g}).
with_content(%r{<driver-class>oracle.jdbc.OracleDriver})
end
end

context 'oracle servicename' do
let(:params) do
{
version: '8.13.5',
javahome: '/opt/java',
db: 'oracle',
dbport: 1522,
dbserver: 'oracleserver',
oracle_use_sid: false,
dbname: 'mydatabase',
}
end

it do
is_expected.to contain_file('/home/jira/dbconfig.xml').
with_content(%r{jdbc:oracle:thin:@oracleserver:1522/mydatabase})
end
end

context 'sqlserver params' do
let(:params) do
{
Expand Down

0 comments on commit 9652ac4

Please sign in to comment.