Puppet Class: tomcat::service::archive
- Defined in:
- manifests/service/archive.pp
Overview
Class: tomcat::service::archive
This class configures the tomcat service when installed from archive
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 74 75 76 |
# File 'manifests/service/archive.pp', line 5
class tomcat::service::archive {
# The base class must be included first
if !defined(Class['tomcat']) {
fail('You must include the tomcat base class before using any tomcat sub class')
}
# forward variables used in templates
$catalina_base_real = $::tomcat::catalina_base_real
$service_start_real = $::tomcat::service_start_real
$service_stop_real = $::tomcat::service_stop_real
$service_name_real = $::tomcat::service_name_real
$config_path_real = $::tomcat::config_path_real
$tomcat_user = $::tomcat::tomcat_user_real
$tomcat_group = $::tomcat::tomcat_group_real
$systemd_service_type_real = $::tomcat::systemd_service_type_real
$notify_service = $::tomcat::restart_on_change ? {
true => Service[$::tomcat::service_name_real],
false => undef,
}
if $::tomcat::params::systemd {
# manage systemd unit on compatible systems
# Template uses:
# - $systemd_service_type_real
# - $service_name_real
# - $config_path_real
# - $service_start_real
# - $service_stop_real
# - $tomcat_user
# - $tomcat_group
file { "${service_name_real} service unit":
path => "/etc/systemd/system/${service_name_real}.service",
owner => 'root',
group => 'root',
content => template("${module_name}/instance/systemd_service_unit.erb")
}
# Refresh systemd configuration
exec { "refresh ${service_name_real}":
command => '/usr/bin/systemctl daemon-reload',
refreshonly => true,
subscribe => File["${service_name_real} service unit"],
notify => $notify_service
}
} else { # Debian, RHEL 6, SLES 11, ...
$start_command = "/bin/su ${tomcat_user} -s /bin/bash -c '${service_start_real}'"
$stop_command = "/bin/su ${tomcat_user} -s /bin/bash -c '${service_stop_real}'"
$status_command = "/usr/bin/pgrep -d , -u ${tomcat_user} -G ${tomcat_group} -f Dcatalina.base=\$CATALINA_BASE"
# create init script
# Template uses:
# - $catalina_base_real
# - $start_command
# - $stop_command
# - $status_command
file { "${service_name_real} service unit":
ensure => present,
path => "/etc/init.d/${service_name_real}",
owner => 'root',
group => 'root',
mode => '0755',
content => template("${module_name}/instance/tomcat_init_generic.erb"),
notify => $notify_service
}
}
service { $service_name_real:
ensure => $::tomcat::service_ensure,
enable => $::tomcat::service_enable,
require => File["${service_name_real} service unit"];
}
}
|