Skip to content

Commit

Permalink
don't override service init mechanism #53
Browse files Browse the repository at this point in the history
  • Loading branch information
deric committed Feb 18, 2016
1 parent 8d95e45 commit b21468f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$tracefile_threshold = 'TRACE',
$max_allowed_connections = undef,
$peer_type = 'UNSET',
$start_with = 'init.d',
$start_with = undef,
$ensure_cron = true,
$service_package = undef,
$service_name = $::zookeeper::params::service_name,
Expand Down Expand Up @@ -130,6 +130,7 @@
cfg_dir => $cfg_dir,
zoo_dir => $zoo_dir,
log_dir => $log_dir,
start_with => $start_with,
service_name => $service_name,
require => Class['zookeeper::config'],
before => Anchor['zookeeper::end'],
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@
}
}
'Redhat': {
case $::operatingsystemmajrelease {
'6': { $initstyle = 'upstart' }
'7': { $initstyle = 'systemd' }
default: { $initstyle = undef }
}
$_os_overrides = {
'packages' => ['zookeeper', 'zookeeper-server'],
'service_name' => 'zookeeper-server',
'start_with' => $initstyle,
}
}

default: {
$_os_overrides = {}
}
Expand Down
14 changes: 2 additions & 12 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class zookeeper::service(
$zoo_dir,
$log_dir,
$start_with = undef, # init mechanism
$cfg_dir = '/etc/zookeeper/conf',
$service_name = 'zookeeper',
$service_ensure = 'running',
Expand All @@ -12,18 +13,7 @@
){
require zookeeper::install

case $::osfamily {
'redhat': {
case $::operatingsystemmajrelease {
'6': { $initstyle = 'upstart' }
'7': { $initstyle = 'systemd' }
default: { $initstyle = 'unknown' }
}
}
default: { $initstyle = 'unknown' }
}

if ($initstyle == 'systemd' and $manage_systemd == true) {
if ($start_with == 'systemd' and $manage_systemd == true) {
file { '/usr/lib/systemd/system/zookeeper.service':
ensure => 'present',
content => template('zookeeper/zookeeper.service.erb'),
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
let(:user) { 'zookeeper' }
let(:group) { 'zookeeper' }

let(:params){{
:zoo_dir => '/usr/lib/zookeeper',
:log_dir => '/var/log/zookeeper',
:start_with => 'systemd',
}}

it { should contain_package('zookeeper') }

it { should contain_file(
Expand Down

0 comments on commit b21468f

Please sign in to comment.