Skip to content

Commit

Permalink
updating service fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jfryman committed Oct 13, 2015
1 parent 887a73d commit 70549dc
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ vendor
bin
pkg
coverage
*.swp
.DS_Store
.bundle
81 changes: 48 additions & 33 deletions manifests/helper/service_manager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,84 @@
# This deined type is used to add service management scripts for the various distros
#
define st2::helper::service_manager (
$process = undef,
$process = $name,
) {
$_package_map = $::st2::params::component_map
$package = $_package_map["${process}"]
$st2_process = "st2${process}"
$init_provider = $::st2::params::init_type
$_package_map = $::st2::params::component_map
$_package = $_package_map["${process}"]
$_init_provider = $::st2::params::init_type
$_subsystem = $::st2::params::subsystem_map[$process]

if $osfamily == 'Debian' {
tag('st2::service_manager')

file { "/etc/init/${process}.conf":
ensure => present,
owner => 'root',
group => 'root',
mode => '0444',
source => "puppet:///modules/st2/etc/init/${st2_process}.conf",
notify => Service["${st2_process}"],
case $_init_type {
'upstart': {
$_init_file = "/etc/init/${_subsystem}.conf"
$_init_mode = '0644'
$_init_source = "puppet:///modules/st2/etc/init/${_subsystem}.conf"
}
} elsif $osfamily == 'RedHat' {
if $operatingsystemmajrelease == '7' {
if $process == 'st2actionrunner' {
'systemd': {
$init_file = undef

# If Actionrunner, we need two init scripts. First is the
# anchor init script, which calls out actionrunner
if $_subsystem == 'st2actionrunner' {
$process_type = 'multi'
file{"/etc/systemd/system/st2actionrunner.service":
file{ "/etc/systemd/system/st2actionrunner.service":
ensure => file,
owner => 'root',
group => 'root',
mode => '0444',
source => "puppet:///modules/st2/systemd/system/st2actionrunner.service",
}

exec{"sysctl enable ${st2_process}":
exec{ "sysctl enable ${_subsystem}":
path => '/bin:/usr/bin:/usr/local/bin',
command => "systemctl --no-reload enable st2actionrunner",
require => File["/etc/systemd/system/st2actionrunner.service"],
notify => Service["${st2_process}"],
}

st2::helper::systemd{ "${st2_process}_multi_systemd":
st2_process => $process,
process_type => $process_type
notify => Service["${_subsystem}"],
}
} else {
$process_type = 'single'
st2::helper::systemd{ "${st2_process}_systemd":
st2_process => $st2_process,
process_type => $process_type
}
}
} elsif $operatingsystemmajrelease == '6' {

# Declare the Subsystem for SystemD.
st2::helper::systemd{ $_subsystem:
st2_process => $_subsystem,
process_type => $process_type,
}
}
'init': {
$_init_file = "/etc/init.d/${_subsystem}"
$_init_mode = '0755'
$_init_source = "puppet:///modules/st2/etc/init.d/${_subsystem}"
}
default: {
fail("[st2::helper::service_manager] Unable to setup init script for init system ${_init_type}. Not supported")
}
}

service { "${st2_process}":
if $_init_file {
file { $_init_file:
ensure => file,
owner => 'root',
group => 'root',
mode => $_init_mode,
source => $_init_source,
notify => Service[$_subsystem],
}
}

service { $_subsystem:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
provider => $init_provider,
subscribe => [
Package["${package}"],
Package["${_package}"],
Package['st2common'],
],
}
File<| tag == 'st2::helper::service_manager' |> ~> Service[$st2_process]

File<| tag == 'st2::service_manager' |> ~> Service[$st2_process]
}
3 changes: 2 additions & 1 deletion manifests/helper/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
} else {
$extra_char = ''
}

$process_name = $st2_process
file{"/etc/systemd/system/${st2_process}${extra_char}.service":
ensure => file,
owner => 'root',
group => 'root',
mode => '0444',
content => template("st2/etc/systemd/system/st2service_${process_type}.service.erb"),
tag => 'st2::service_manager',
}

if $process_type == 'single' {
Expand Down
16 changes: 16 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@
rulesengine => 'st2reactor',
sensorcontainer => 'st2reactor',
}
$subsystem_map = {
actionrunner => 'st2actionrunner',
api => 'st2api',
auth => 'st2auth',
notifier => 'st2notifier',
resultstracker => 'st2resultstracker',
rulesengine => 'st2rulesengine',
sensorcontainer => 'st2sensorcontainer',
st2actionrunner => 'st2actionrunner',
st2api => 'st2api',
st2auth => 'st2auth',
st2notifier => 'st2notifier',
st2resultstracker => 'st2resultstracker',
st2rulesengine => 'st2rulesengine',
st2sensorcontainer => 'st2sensorcontainer',
}

# Non-user configurable parameters
$repo_url = 'https://github.com/StackStorm/st2'
Expand Down

0 comments on commit 70549dc

Please sign in to comment.