Puppet Class: mirthconnect::mirthconnect

Defined in:
manifests/mirthconnect.pp

Overview

Class mirthconnect::mirthconnect

This define handles the packages and prerequisites for installing Mirthconnect.

Parameters

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’

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

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

Provide some examples on how to use this type:

class { 'mirthconnect::mirthconnect':
  provider => 'rpm' # RPM is the default.
}

class { 'mirthconnect::mirthconnect':
  provider     => 'rpm' # RPM is the default.
  rpm_source   => 'www.foo.com/mirth-1.2.1.rpm' # change the source RPM
}

# Install via yum. This must be accessible to the client as a prerequisite via the EULA.
class { 'mirthconnect::mirthconnect':
  provider => 'yum',
}

# Install but change the administrator password.
class { 'mirthconnect::mirthconnect':
  admin_password => 'foo',
}

Authors

Marcus Young <myoung34@my.apsu.edu>

The MIT License (MIT)

Copyright © 2014 Marcus Young

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Parameters:

  • admin_password (Any) (defaults to: $mirthconnect::admin_password)
  • db_dbname (Any) (defaults to: $mirthconnect::params::db_dbname)
  • db_host (Any) (defaults to: $mirthconnect::params::db_host)
  • db_pass (Any) (defaults to: $mirthconnect::params::db_pass)
  • db_port (Any) (defaults to: $mirthconnect::params::db_port)
  • db_provider (Any) (defaults to: $mirthconnect::params::db_provider)
  • db_user (Any) (defaults to: $mirthconnect::params::db_user)
  • java_version (Any) (defaults to: $mirthconnect::params::java_version)
  • provider (Any) (defaults to: $mirthconnect::provider)
  • rpm_source (Any) (defaults to: $mirthconnect::params::rpm_source)
  • tarball_source (Any) (defaults to: $mirthconnect::params::tarball_source)


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'manifests/mirthconnect.pp', line 100

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,
  $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 $::operatingsystem =~ /Amazon/ {
      if $provider != 'source' {
        fail("AWS Linux does not support package source ${provider}")
      }
    }
  } else {
    fail('Your operating system is not supported')
  }

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

  firewall { '106 allow mirthconnect':
    action => accept,
    port   => [
      8080, 8443
    ],
    proto  => tcp,
  }

  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,
      }

      if($rpm_source =~ /3.4.0.8000.b1959/) {
        file { '/tmp/mirth_340_fix.sh':
          ensure  => present,
          before  => Exec['set mirthconnect password'],
          content => template('mirthconnect/mirth_340_fix.sh.erb'),
          require => Package['mirthconnect'],
        }

        exec { 'fix mirth 3.4.0 install':
          before  => Exec['set mirthconnect password'],
          command => 'bash /tmp/mirth_340_fix.sh',
          creates => '/opt/mirthconnect/cli-lib/jersey-common-2.22.1.jar',
          path    => $::path,
          require => File['/tmp/mirth_340_fix.sh'],
        }
      }
    }
    'yum': {
      package { 'mirthconnect':
        ensure   => latest,
        before   => [
          File['/opt/mirthconnect'],
          File['/etc/init.d/mirthconnect'],
        ],
        require  => [
          Class['java'],
        ],
        provider => yum,
      }

      file { '/opt/mirthconnect':
        ensure => directory,
      }
    }
    default: {
      fail("Unsupported provider ${provider}")
    }
  }

  file { '/etc/init.d/mirthconnect':
    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}",
      }
      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}",
      }
      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}",
      }
      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}",
      }
    }
    default: {
      fail("Unsupported database provider '${db_provider}' supplied.")
    }
  }

  service { 'mirthconnect':
    ensure     => 'running',
    enable     => true,
    hasrestart => true,
    hasstatus  => true,
    require    => [
      File['/etc/init.d/mirthconnect'],
    ],
  }

  file { '/tmp/mirthconnect_pw_reset':
    ensure    => present,
    content   => template('mirthconnect/mirthconnect_pw_reset.erb'),
    replace   => true,
    subscribe => Service['mirthconnect'],
  }

  exec { 'set mirthconnect password':
    command     => 'sleep 60; /opt/mirthconnect/mccommand -u admin -p admin -s /tmp/mirthconnect_pw_reset; mysql -uroot mirthdb -e "insert into person_preference (PERSON_ID,NAME,VALUE) values (1,\'firstlogin\',\'false\');"',
    path        => $::path,
    refreshonly => true,
    subscribe   => File['/tmp/mirthconnect_pw_reset'],
  }

  Package <| |> -> Archive <| |> -> Exec <| |>
}