Skip to content

Commit

Permalink
Issue 6: Add support for building from source
Browse files Browse the repository at this point in the history
  • Loading branch information
myoung34 committed Dec 12, 2014
1 parent 3300814 commit 0a7b0c4
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 306 deletions.
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
fixtures:
forge_modules:
archive:
repo: "nanliu/archive"
ref: "0.1.8"
firewall:
repo: "puppetlabs/firewall"
ref: "1.2.0"
Expand Down
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ About
Supported Versions (tested)
=================
## OS ##
* AWS Linux
* Mirth Connect Base install (Mirth Connect not pre-installed)
* 3.0.2.7140.b1159 (from source only)
* CentOS 6
* Mirth Connect Base install (Mirth Connect not pre-installed)
* 3.0.2.7140.b1159
Expand All @@ -26,10 +29,6 @@ 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'
Expand All @@ -48,6 +47,13 @@ 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'
* *provider*
* The provider to download the MirthConnect package from. Can be one of 'rpm', 'source', or 'yum'.
* *rpm_source*
* The source of the RPM if using the 'rpm' provider.
* *tarball_source*
* Optional source of the source tarball.
* Not optional if using the 'source' provider.

Quick Start
===========
Expand Down Expand Up @@ -75,15 +81,16 @@ Quick Start
Hiera
=====

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'
mirthconnect::admin_password: 'admin'
mirthconnect::db_dbname: 'mirthdb'
mirthconnect::db_host: 'localhost'
mirthconnect::db_pass: 'abc1234'
mirthconnect::db_port: '3306'
mirthconnect::db_provider: 'mysql'
mirthconnect::db_user: 'mirth'
mirthconnect::provider: 'rpm'
mirthconnect::rpm_source: 'www.foo.com/mirth.rpm'
mirthconnect::tarball_source: 'www.foo.com/mirth.tar.gz'

Testing
=====
Expand Down
10 changes: 8 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@
# 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'.
# The provider to download the MirthConnect package from.
# Can be one of 'rpm', 'source', or 'yum'.
#
# [*rpm_source*]
# The source of the RPM if using the 'rpm' provider.
#
# [*tarball_source*]
# Optional source of the source tarball.
# Not optional if using the 'source' provider.
#
# === Examples
#
# class { 'mirthconnect':
Expand Down Expand Up @@ -97,6 +101,7 @@
$db_user = $mirthconnect::params::db_user,
$provider = $mirthconnect::params::provider,
$rpm_source = $mirthconnect::params::rpm_source,
$tarball_source = $mirthconnect::params::tarball_source,
) inherits mirthconnect::params {
class { 'mirthconnect::mirthconnect':
admin_password => $admin_password,
Expand All @@ -108,5 +113,6 @@
db_user => $db_user,
provider => $provider,
rpm_source => $rpm_source,
tarball_source => $tarball_source,
}
}
74 changes: 61 additions & 13 deletions manifests/mirthconnect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
# 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'.
# The provider to download the MirthConnect package from.
# Can be one of 'rpm', 'source', or 'yum'.
#
# [*rpm_source*]
# The source of the RPM if using the 'rpm' provider.
# Optional source of the RPM.
# Not optional if using the 'rpm' provider.
#
# [*tarball_source*]
# Optional source of the source tarball.
# Not optional if using the 'source' provider.
#
# === Examples
#
Expand Down Expand Up @@ -99,10 +104,14 @@
$db_user = $mirthconnect::params::db_user,
$provider = $mirthconnect::provider,
$rpm_source = $mirthconnect::params::rpm_source,
$tarball_source = $mirthconnect::params::tarball_source,
) {
if $::osfamily != 'RedHat' or $::operatingsystem =~ /Amazon/ {
if $::osfamily != 'RedHat' {
fail('Your operating system is not supported')
}
if $::operatingsystem =~ /Amazon/ and $provider != 'source' {
fail("AWS Linux does not support package source ${provider}")
}

firewall { '106 allow mirthconnect':
action => accept,
Expand All @@ -118,19 +127,53 @@
}

case $provider {
'source': {
package { 'faraday_middleware':
ensure => 'installed',
provider => 'gem',
}->

archive { '/tmp/mirthconnect.tar.gz':
ensure => present,
before => File['/etc/init.d/mirthconnect'],
extract => true,
extract_path => '/opt',
source => $tarball_source,
cleanup => true,
}->

file { '/opt/mirthconnect':
ensure => link,
target => '/opt/Mirth Connect',
}
}
'rpm': {
package { 'mirthconnect':
ensure => latest,
before => [
File['/opt/mirthconnect'],
File['/etc/init.d/mirthconnect'],
],
provider => rpm,
require => Class['java'],
source => $rpm_source,
}

file { '/opt/mirthconnect':
ensure => directory,
}
}
'yum': {
package { 'mirthconnect':
ensure => latest,
before => [
File['/opt/mirthconnect'],
File['/etc/init.d/mirthconnect'],
],
provider => yum,
require => Class['java'],
}

file { '/opt/mirthconnect':
ensure => directory,
}
}
default: {
Expand All @@ -142,34 +185,39 @@
ensure => link,
target => '/opt/mirthconnect/mcservice',
}

case $db_provider {
'derby': {
}
'mysql': {
$properties_file = '/opt/mirthconnect/conf/mirth.properties'
exec { 'ConfSetDb':
before => Service['mirthconnect'],
command => "sed -i.bak 's/database \\?=.*/database = mysql/g' ${properties_file}",
path => $::path,
require => File['/opt/mirthconnect'],
unless => "grep -E 'database\s*=\s*mysql' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbUrl':
before => Service['mirthconnect'],
command => "sed -i.bak 's/database.url \\?=.*/database.url = jdbc:mysql:\\/\\/${db_host}:${db_port}\\/${db_dbname}/g' ${properties_file}",
path => $::path,
require => File['/opt/mirthconnect'],
unless => "grep -E 'database.url\s*=\s*jdbc:mysql://${db_host}:${db_port}/${db_dbname}' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbUser':
before => Service['mirthconnect'],
command => "sed -i.bak 's/database.username \\?=.*/database.username = ${db_user}/g' ${properties_file}",
path => $::path,
require => File['/opt/mirthconnect'],
unless => "grep -E 'database.username\s*=\s*${db_user}' ${properties_file}",
require => Package['mirthconnect'],
}
exec { 'ConfSetDbPass':
before => Service['mirthconnect'],
command => "sed -i.bak 's/database.password \\?=.*/database.password = ${db_pass}/g' ${properties_file}",
path => $::path,
require => File['/opt/mirthconnect'],
unless => "grep -E 'database.password\s*=\s*${db_pass}' ${properties_file}",
require => Package['mirthconnect'],
}
}
default: {
Expand All @@ -183,7 +231,7 @@
hasrestart => true,
hasstatus => true,
require => [
Package['mirthconnect'],
Class['Java'],
File['/etc/init.d/mirthconnect'],
],
}
Expand All @@ -192,7 +240,7 @@
ensure => present,
content => template('mirthconnect/mirthconnect_pw_reset.erb'),
replace => true,
subscribe => Package['mirthconnect'],
subscribe => Service['mirthconnect'],
}

exec { 'set mirthconnect password':
Expand All @@ -202,5 +250,5 @@
subscribe => File['/tmp/mirthconnect_pw_reset'],
}

Class['java'] -> Package['mirthconnect'] -> Service['mirthconnect'] -> File['/tmp/mirthconnect_pw_reset'] -> Exec['set mirthconnect password']
Package <| |> -> Archive <| |> -> Exec <| |>
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
$db_user = ''
$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'
}
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": [
{ "name": "puppetlabs/firewall", "version_requirement": ">= 1.2.0" },
{ "name": "puppetlabs/java", "version_requirement": ">= 1.1.1" }
{ "name": "nanliu/archive", "version_requirement": ">= 0.1.8" }
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.1" },
]
}
96 changes: 0 additions & 96 deletions spec/classes/mirthconnect_db_spec.rb

This file was deleted.

0 comments on commit 0a7b0c4

Please sign in to comment.