Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/stackstorm/puppet-st2 int…
Browse files Browse the repository at this point in the history
…o sysv-scripts
  • Loading branch information
jfryman committed Oct 13, 2015
2 parents 8979d20 + f4b37da commit 9822c36
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,6 @@ vendor
bin
pkg
coverage
*.swp
.DS_Store
.bundle
97 changes: 52 additions & 45 deletions manifests/helper/service_manager.pp
Expand Up @@ -6,74 +6,81 @@
$process = $name,
) {
$_package_map = $::st2::params::component_map
$package = $_package_map["${process}"]
$st2_process = "st2${process}"
$_init_provider = $::st2::params::init_type
$_package = $_package_map["${process}"]
$_init_type = $::st2::params::init_type
$_subsystem = $::st2::params::subsystem_map[$process]

case $_init_provider {
tag('st2::service_manager')

case $_init_type {
'upstart': {
file { "/etc/init/${process}.conf":
ensure => present,
owner => 'root',
group => 'root',
mode => '0444',
source => "puppet:///modules/st2/etc/init/${process}.conf",
notify => Service["${st2_process}"],
}
$_init_file = "/etc/init/${_subsystem}.conf"
$_init_mode = '0644'
$_init_source = "puppet:///modules/st2/etc/init/${_subsystem}.conf"
}
'systemd': {
if $process == 'st2actionrunner' {
$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":
ensure => file,
owner => 'root',
group => 'root',
mode => '0444',
source => "puppet:///modules/st2/systemd/system/st2actionrunner.service",
notify => Exec["sysctl enable ${st2_process}"],
ensure => file,
owner => 'root',
group => 'root',
mode => '0444',
source => "puppet:///modules/st2/systemd/system/st2actionrunner.service",
}

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

st2::helper::systemd{ "${st2_process}_multi_systemd":
st2_process => $process,
process_type => $process_type
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["${_subsystem}"],
}
} else {
$process_type = 'single'
st2::helper::systemd{ "${st2_process}_systemd":
st2_process => $st2_process,
process_type => $process_type
}
}

# Declare the Subsystem for SystemD.
st2::helper::systemd{ $_subsystem:
st2_process => $_subsystem,
process_type => $process_type,
}
}
'init': {
file { "/etc/init.d/${process}":
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
source => "puppet:///modules/st2/etc/init.d/${process}.conf",
notify => Service[$st2_process],
}
$_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,
provider => $_init_type,
subscribe => [
Package["${package}"],
Package["${_package}"],
Package['st2common'],
],
}

File<| tag == 'st2::service_manager' |> ~> Service[$_subsystem]
}
3 changes: 2 additions & 1 deletion manifests/helper/systemd.pp
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
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 9822c36

Please sign in to comment.