Puppet Class: maestro::maestro::service

Inherits:
maestro::params
Defined in:
manifests/maestro/service.pp

Overview

Parameters:

  • enabled (Any) (defaults to: $maestro::params::enabled)
  • db_password (Any) (defaults to: $maestro::params::db_password)
  • jdbc_users (Any) (defaults to: $maestro::maestro::jdbc_users)
  • basedir (Any) (defaults to: $maestro::maestro::basedir)
  • port (Any) (defaults to: $maestro::maestro::port)
  • lucee (Any) (defaults to: $maestro::maestro::lucee)
  • ldap (Any) (defaults to: $maestro::maestro::ldap)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'manifests/maestro/service.pp', line 1

class maestro::maestro::service(
  $enabled     = $maestro::params::enabled,
  $db_password = $maestro::params::db_password,
  $jdbc_users  = $maestro::maestro::jdbc_users,
  $basedir     = $maestro::maestro::basedir,
  $port        = $maestro::maestro::port,
  $lucee       = $maestro::maestro::lucee,
  $ldap        = $maestro::maestro::ldap) inherits maestro::params {

  # not needed in Maestro 4.18.0+ RPM
  if ($maestro::maestro::package_type == 'tarball') or (versioncmp($maestro::maestro::version, '4.18.0') < 0) {
    file { '/etc/init.d/maestro':
      owner   => 'root',
      mode    => '0755',
      content => template('maestro/maestro.erb'),
      require => Class['maestro::maestro::package'],
      notify  => Service['maestro'],
    }
  }

  # do this only for binary installations, not for webapp deployments
  # Wait for tables to be created on Maestro startup
  # not actually used in the maestro module but useful for other modules that need to depend on maestro db being ready
  $startup_wait_script = '/tmp/startup_wait.sh'
  if $enabled {
    file { $startup_wait_script:
      mode    =>  '0700',
      content =>  template('maestro/startup_wait.sh.erb'),
    } ->
    exec { "check-maestro-up":
      command     => "${startup_wait_script} ${db_password} >> ${basedir}/logs/maestro_initdb.log 2>&1",
      alias       => 'startup_wait',
      timeout     => 600,
      refreshonly => true,
      subscribe   => [Service[maestro]],
    }
    if $lucee {
      exec { 'check-data-upgrade':
        command     => "curl --noproxy localhost -X POST http://localhost:${port}/api/v1/system/upgrade",
        logoutput   => 'on_failure',
        tries       => 300,
        try_sleep   => 1,
        subscribe   => Exec['startup_wait'],
        refreshonly => true,
        path        => "/usr/bin",
      }
    }
  }

  # LDAP default system admin user, add permissions
  if !empty($ldap) {
    exec { 'insert-ldap-default-admin' :
      command     => "psql -h localhost -d maestro -U maestro -c \
      \"delete from userassignment where id=-1; insert into userassignment values(-1, '*', '${maestro::maestro::ldap['admin_user']}', (select id from role where name='System Administrator') );\"",
      unless      => "psql -h localhost -d maestro -U maestro -c \
      \"select username from userassignment where id=-1;\" | grep '${maestro::maestro::ldap['admin_user']}'",
      environment => "PGPASSWORD=${db_password}",
      path        => '/bin/:/usr/bin',
      logoutput   => true,
      require     => Exec['startup_wait'],
    }
  }

  $ensure_service = $enabled ? { true => running, false => stopped, }
  service { 'maestro':
    ensure     => $ensure_service,
    hasrestart => true,
    hasstatus  => true,
    enable     => $enabled,
    require    => [Class['maestro::maestro::package', 'maestro::maestro::db']],
    subscribe  => [File["${basedir}/conf/jetty.xml"], File["${basedir}/conf/security.properties"]],
  }
}