Skip to content

Commit

Permalink
Added support for specifying java version. Also changed default versi…
Browse files Browse the repository at this point in the history
…on from 3.0.2 to 3.4.0
  • Loading branch information
myoung34 committed May 24, 2016
1 parent 65b64cc commit dad7100
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 56 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Supported Versions (tested)
## OS ##
* AWS Linux
* Mirth Connect Base install (Mirth Connect not pre-installed)
* 3.0.2.7140.b1159 (from source only)
* 3.4.0.8000.b1959 (from source only)
* CentOS 6
* Mirth Connect Base install (Mirth Connect not pre-installed)
* 3.0.2.7140.b1159
* 3.4.0.8000.b1959

Prerequisites
=============
Expand Down Expand Up @@ -50,6 +50,8 @@ Parameters
* *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'
* *java_version*
* Optional java version to install. Defaults to 'java-1.8.0-openjdk'
* *provider*
* The provider to download the MirthConnect package from. Can be one of 'rpm', 'source', or 'yum'.
* *rpm_source*
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
# Optional database user for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*java_version*]
# Optional java version to install. Defaults to 'java-1.8.0-openjdk'
#
# [*provider*]
# The provider to download the MirthConnect package from.
# Can be one of 'rpm', 'source', or 'yum'.
Expand Down Expand Up @@ -99,6 +102,7 @@
$db_port = $mirthconnect::params::db_port,
$db_provider = $mirthconnect::params::db_provider,
$db_user = $mirthconnect::params::db_user,
$java_version = $mirthconnect::params::java_version,
$provider = $mirthconnect::params::provider,
$rpm_source = $mirthconnect::params::rpm_source,
$tarball_source = $mirthconnect::params::tarball_source,
Expand All @@ -111,6 +115,7 @@
db_port => $db_port,
db_provider => $db_provider,
db_user => $db_user,
java_version => $java_version,
provider => $provider,
rpm_source => $rpm_source,
tarball_source => $tarball_source,
Expand Down
33 changes: 20 additions & 13 deletions manifests/mirthconnect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
# Optional database user for mirth to use in the mirth.properties file.
# Not optional if the *db_provider* is set to anything but 'derby'
#
# [*java_version*]
# Optional java version to install. Defaults to 'java-1.8.0-openjdk'
#
# [*provider*]
# The provider to download the MirthConnect package from.
# The provider to download the MirthConnect package from.
# Can be one of 'rpm', 'source', or 'yum'.
#
# [*rpm_source*]
Expand Down Expand Up @@ -102,18 +105,24 @@
$db_port = $mirthconnect::params::db_port,
$db_provider = $mirthconnect::params::db_provider,
$db_user = $mirthconnect::params::db_user,
$java_version = $mirthconnect::params::java_version,
$provider = $mirthconnect::provider,
$rpm_source = $mirthconnect::params::rpm_source,
$tarball_source = $mirthconnect::params::tarball_source,
) {
if $::osfamily != 'RedHat' {
if $::osfamily == 'Linux' and $::operatingsystem =~ /Amazon/ {
if $::osfamily == 'RedHat' {
if $::operatingsystem =~ /Amazon/ {
if $provider != 'source' {
fail("AWS Linux does not support package source ${provider}")
}
} else {
fail('Your operating system is not supported')
}
} else {
fail('Your operating system is not supported')
}

class { 'java':
version => 'present',
package => $java_version,
}

firewall { '106 allow mirthconnect':
Expand All @@ -124,14 +133,6 @@
proto => tcp,
}

if $::osfamily != 'Linux' {
class { 'java':
before => Service['mirthconnect'],
version => 'present',
package => 'java-1.7.0-openjdk',
}
}

case $provider {
'source': {
package { 'faraday_middleware':
Expand Down Expand Up @@ -161,6 +162,9 @@
File['/etc/init.d/mirthconnect'],
],
provider => rpm,
require => [
Class['java'],
],
source => $rpm_source,
}

Expand All @@ -175,6 +179,9 @@
File['/opt/mirthconnect'],
File['/etc/init.d/mirthconnect'],
],
require => [
Class['java'],
],
provider => yum,
}

Expand Down
5 changes: 3 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
$db_port = ''
$db_provider = 'derby'
$db_user = ''
$java_version = 'java-1.8.0-openjdk'
$provider = 'rpm'
$rpm_source = 'http://downloads.mirthcorp.com/connect/3.0.2.7140.b1159/mirthconnect-3.0.2.7140.b1159-linux.rpm'
$tarball_source = 'http://downloads.mirthcorp.com/connect/3.0.2.7140.b1159/mirthconnect-3.0.2.7140.b1159-unix.tar.gz'
$rpm_source = 'http://downloads.mirthcorp.com/connect/3.4.0.8000.b1959/mirthconnect-3.4.0.8000.b1959-linux.rpm'
$tarball_source = 'http://downloads.mirthcorp.com/connect/3.4.0.8000.b1959/mirthconnect-3.4.0.8000.b1959-unix.tar.gz'
}
72 changes: 33 additions & 39 deletions spec/classes/mirthconnect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@
'provider' => provider,
}}

if osfamily == 'Linux' and operatingsystem == 'Amazon'
it {
expect {
should contain_package('mirthconnect')
}.to raise_error(Puppet::Error, /AWS Linux does not support package source/)
}
else
it { should contain_package('mirthconnect').with_ensure('latest').with_provider(provider) }
it { should contain_file('/opt/mirthconnect').with_ensure('directory') }
if osfamily == 'RedHat'
if operatingsystem == 'Amazon'
it {
expect {
should contain_package('mirthconnect')
}.to raise_error(Puppet::Error, /AWS Linux does not support package source/)
}
else
it { should contain_package('mirthconnect').with_ensure('latest').with_provider(provider) }
it { should contain_file('/opt/mirthconnect').with_ensure('directory') }
end
end
end

Expand All @@ -102,13 +104,11 @@
end

if osfamily != 'RedHat'
if osfamily != 'Linux' and operatingsystem != 'Amazon'
it {
expect {
should contain_class('mirthconnect')
}.to raise_error(Puppet::Error, /Your operating system is not supported/)
}
end
it {
expect {
should contain_class('mirthconnect')
}.to raise_error(Puppet::Error, /Your operating system is not supported/)
}
end
let(:firewall_params) { {
'action' => 'accept',
Expand All @@ -117,11 +117,8 @@
} }
it { should contain_firewall('106 allow mirthconnect').with(firewall_params) }

if osfamily != 'Linux'
it { should contain_class('java').with_before('Service[mirthconnect]').with_distribution('jdk') }
else
it { should_not contain_class('java') }
end
it { should contain_class('java').with_distribution('jdk') }

it { should contain_file('/etc/init.d/mirthconnect').with_ensure('link').with_target('/opt/mirthconnect/mcservice') }
it { should_not contain_exec('ConfSetDb') }
it { should_not contain_exec('ConfSetDbUrl') }
Expand All @@ -133,9 +130,6 @@
'enable' => 'true',
'hasrestart' => 'true',
'hasstatus' => 'true',
'require' => [
'File[/etc/init.d/mirthconnect]',
]
} }
it { should contain_service('mirthconnect').with(service_params) }

Expand All @@ -158,58 +152,58 @@
describe 'mirthconnect' do
describe 'AWS Linux' do
context 'rpm provider' do
it_should_behave_like "mirthconnect redhat", 'rpm', 'Linux', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'Linux', 'Amazon'
it_should_behave_like "mirthconnect redhat", 'rpm', 'RedHat', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'RedHat', 'Amazon'

describe 'database' do
context 'derby db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'derby'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'derby'
end

context 'mysql db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
end

context 'unknown db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'watdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'watdb'
end
end
end

context 'yum provider' do
it_should_behave_like "mirthconnect redhat", 'yum', 'Linux', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'Linux', 'Amazon'
it_should_behave_like "mirthconnect redhat", 'yum', 'RedHat', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'RedHat', 'Amazon'

describe 'database' do
context 'derby db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'derby'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'derby'
end

context 'mysql db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
end

context 'unknown db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'watdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'watdb'
end
end
end

context 'source provider' do
it_should_behave_like "mirthconnect source", 'Linux', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'Linux', 'Amazon'
it_should_behave_like "mirthconnect source", 'RedHat', 'Amazon'
it_should_behave_like "mirthconnect", 'bar', 'RedHat', 'Amazon'

describe 'database' do
context 'derby db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'derby'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'derby'
end

context 'mysql db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'mysql', 'localhost', '3306', 'dbusername', 'secure123', 'mirthdb'
end

context 'unknown db' do
it_should_behave_like 'database', 'Linux', 'Amazon', 'watdb'
it_should_behave_like 'database', 'RedHat', 'Amazon', 'watdb'
end
end
end
Expand Down

0 comments on commit dad7100

Please sign in to comment.