Skip to content

Commit

Permalink
Isusue 7: Add support for MySQL database backend
Browse files Browse the repository at this point in the history
  • Loading branch information
myoung34 authored and Marcus Young committed Dec 11, 2014
1 parent d0fd808 commit 6cd6a14
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 10 deletions.
12 changes: 9 additions & 3 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
fixtures:
forge_modules:
firewall: "puppetlabs/firewall"
java: "puppetlabs/java"
stdlib: "puppetlabs/stdlib"
firewall:
repo: "puppetlabs/firewall"
ref: "1.1.0"
java:
repo: "puppetlabs/java"
ref: "1.1.1"
stdlib:
repo: "puppetlabs/stdlib"
ref: "4.2.1"
symlinks:
mirthconnect: "#{source_dir}"
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@ Prerequisites
1. Yum repository with Mirth Connect RPMs available (The EULA does not allow redistribution) if using the 'yum' provider (see usage).
1. Valid license information

Parameters
===========
* *admin_password*
* The password to set the admin password to post-install.
* *rpm_source*
* The source of the RPM if using the 'rpm' provider.
* *provider*
* The provider to download the MirthConnect package from. Can Be 'yum' or 'rpm'.
* *db_dbname*
* Optional database name for mirth to use in the mirth.properties file.
* Not optional if the *db_provider* is set to anything but 'derby'
* *db_host*
* Optional database hostname for mirth to use in the mirth.properties file.
* Not optional if the *db_provider* is set to anything but 'derby'
* *db_pass*
* Optional database password for mirth to use in the mirth.properties file.
* Not optional if the *db_provider* is set to anything but 'derby
* *db_port*
* Optional database port for mirth to use in the mirth.properties file.
* Not optional if the *db_provider* is set to anything but 'derby'
* *db_provider*
* Optional database provider for mirth to use in the mirth.properties file.
* Currently the only valid strings are 'derby' or 'mysql'
* *db_user*
* Optional database user for mirth to use in the mirth.properties file.
* Not optional if the *db_provider* is set to anything but 'derby'

Quick Start
===========

Expand All @@ -48,16 +75,22 @@ Quick Start
Hiera
=====

mirthconnect::admin_password: 'admin'
mirthconnect::rpm_source: 'www.foo.com/mirth.rpm'
mirthconnect::provider: 'rpm'

mirthconnect::admin_password:'admin'
mirthconnect::rpm_source: 'www.foo.com/mirth.rpm'
mirthconnect::provider: 'rpm'
mirthconnect::db_dbname: 'mirthdb'
mirthconnect::db_host: 'localhost'
mirthconnect::db_pass: 'abc1234'
mirthconnect::db_port: '3306'
mirthconnect::db_provider: 'mysql'
mirthconnect::db_user: 'mirth'

Testing
=====

* Run the default tests (puppet + lint)
bundle install

bundle install
bundle exec rake

* Run the [beaker](https://github.com/puppetlabs/beaker) acceptance tests
Expand Down
9 changes: 9 additions & 0 deletions default.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class { 'mirthconnect':
provider => 'rpm',
admin_password => 'mypass',
db_host => 'localhost',
db_port => '3306',
db_user => 'mirth',
db_dbname => 'mirthdb',
db_pass => 'foo',
}
36 changes: 36 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@
# [*admin_password*]
# The password to set the admin password to post-install.
#
# [*db_dbname*]
# Optional database name for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_host*]
# Optional database hostname for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_pass*]
# Optional database password for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_port*]
# Optional database port for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_provider*]
# Optional database provider for mirth to use in the mirth.properties file.
# Currently the only valid strings are 'derby' or 'mysql'
#
# [*db_user*]
# Optional database user for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*provider*]
# The provider to download the MirthConnect package from. Can
# Be 'yum' or 'rpm'.
Expand Down Expand Up @@ -65,11 +89,23 @@
#
class mirthconnect (
$admin_password = $mirthconnect::params::admin_password,
$db_dbname = $mirthconnect::params::db_dbname,
$db_host = $mirthconnect::params::db_host,
$db_pass = $mirthconnect::params::db_pass,
$db_port = $mirthconnect::params::db_port,
$db_provider = $mirthconnect::params::db_provider,
$db_user = $mirthconnect::params::db_user,
$provider = $mirthconnect::params::provider,
$rpm_source = $mirthconnect::params::rpm_source,
) inherits mirthconnect::params {
class { 'mirthconnect::mirthconnect':
admin_password => $admin_password,
db_dbname => $db_dbname,
db_host => $db_host,
db_pass => $db_pass,
db_port => $db_port,
db_provider => $db_provider,
db_user => $db_user,
provider => $provider,
rpm_source => $rpm_source,
}
Expand Down
68 changes: 68 additions & 0 deletions manifests/mirthconnect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@
# [*admin_password*]
# The password to set the admin password to post-install.
#
# [*db_dbname*]
# Optional database name for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_host*]
# Optional database hostname for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_pass*]
# Optional database password for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_port*]
# Optional database port for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*db_provider*]
# Optional database provider for mirth to use in the mirth.properties file.
# Currently the only valid strings are 'derby' or 'mysql'
#
# [*db_user*]
# Optional database user for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*provider*]
# The provider to download the MirthConnect package from. Can
# Be 'yum' or 'rpm'.
Expand Down Expand Up @@ -67,9 +91,19 @@
#
class mirthconnect::mirthconnect (
$admin_password = $mirthconnect::admin_password,
$db_dbname = $mirthconnect::params::db_dbname,
$db_host = $mirthconnect::params::db_host,
$db_pass = $mirthconnect::params::db_pass,
$db_port = $mirthconnect::params::db_port,
$db_provider = $mirthconnect::params::db_provider,
$db_user = $mirthconnect::params::db_user,
$provider = $mirthconnect::provider,
$rpm_source = $mirthconnect::params::rpm_source,
) {
if $::osfamily != 'RedHat' or $::operatingsystem =~ /Amazon/ {
fail("Your operating system is not supported")
}

firewall { '106 allow mirthconnect':
action => accept,
port => [
Expand Down Expand Up @@ -108,6 +142,40 @@
ensure => link,
target => '/opt/mirthconnect/mcservice',
}
case $db_provider {
'derby': {
}
'mysql': {
$properties_file = '/opt/mirthconnect/conf/mirth.properties'
exec { 'ConfSetDb':
command => "sed -i.bak 's/database \\?=.*/database = mysql/g' ${properties_file}",
path => $::path,
unless => "grep -E 'database\s*=\s*mysql' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbUrl':
command => "sed -i.bak 's/database.url \\?=.*/database.url = jdbc:mysql:\\/\\/${db_host}:${db_port}\\/${db_dbname}/g' ${properties_file}",
path => $::path,
unless => "grep -E 'database.url\s*=\s*jdbc:mysql://${db_host}:${db_port}/${db_dbname}' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbUser':
command => "sed -i.bak 's/database.username \\?=.*/database.username = ${db_user}/g' ${properties_file}",
path => $::path,
unless => "grep -E 'database.username\s*=\s*${db_user}' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbPass':
command => "sed -i.bak 's/database.password \\?=.*/database.password = ${db_pass}/g' ${properties_file}",
path => $::path,
unless => "grep -E 'database.password\s*=\s*${db_pass}' ${properties_file}",
require => Package['mirthconnect'],
}
}
default: {
fail("Unsupported database provider '${db_provider}' supplied.")
}
}

service { 'mirthconnect':
ensure => 'running',
Expand Down
6 changes: 6 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
#
class mirthconnect::params {
$admin_password = 'admin'
$db_dbname = ''
$db_host = ''
$db_pass = ''
$db_port = ''
$db_provider = 'derby'
$db_user = ''
$provider = 'rpm'
$rpm_source = 'http://downloads.mirthcorp.com/connect/3.0.2.7140.b1159/mirthconnect-3.0.2.7140.b1159-linux.rpm'
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}
],
"dependencies": [
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.1" },
{ "name": "puppetlabs/firewall", "version_requirement": ">= 1.1.0" },
{ "name": "puppetlabs/java", "version_requirement": ">= 1.1.1" }
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.1" },
]
}

0 comments on commit 6cd6a14

Please sign in to comment.