From 22c03e86f946a24f92c200f36c3dbcd417105f00 Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Wed, 16 Sep 2015 16:39:14 +0200 Subject: [PATCH] reintroduce `manage_systemd` parameter #26 Currently defaults to `true` --- README.md | 3 ++- manifests/init.pp | 10 ++++++---- manifests/service.pp | 4 ++-- spec/classes/service_spec.rb | 13 +++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bce406e71..06b17747a 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,8 @@ This is a workaround for a a [Facter issue](https://tickets.puppetlabs.com/brows - `snap_retain_count` - number of snapshots that will be kept after purging (since ZooKeeper 3.4.0) - `min_session_timeout` - the minimum session timeout in milliseconds that the server will allow the client to negotiate. Defaults to 2 times the **tickTime** (since ZooKeeper 3.3.0) - `max_session_timeout` - the maximum session timeout in milliseconds that the server will allow the client to negotiate. Defaults to 20 times the **tickTime** (since ZooKeeper 3.3.0) - - `manage_service` (default: `true`) whether Puppet should ensure running service, on RHEL 7.0 a service configuration will be created if none exists + - `manage_service` (default: `true`) whether Puppet should ensure running service + - `manage_systemd` when enabled on RHEL 7.0 a service configuration will be managed and many others, see the `init.pp` file for more details. diff --git a/manifests/init.pp b/manifests/init.pp index a53fb1e0e..50970bdb3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -58,6 +58,7 @@ $min_session_timeout = undef, $max_session_timeout = undef, $manage_service = true, + $manage_systemd = true, ) { validate_array($packages) @@ -112,10 +113,11 @@ if ($manage_service) { class { 'zookeeper::service': - cfg_dir => $cfg_dir, - service_name => $service_name, - require => Class['zookeeper::config'], - before => Anchor['zookeeper::end'], + cfg_dir => $cfg_dir, + service_name => $service_name, + require => Class['zookeeper::config'], + before => Anchor['zookeeper::end'], + manage_systemd => $manage_systemd, } } anchor { 'zookeeper::end': } diff --git a/manifests/service.pp b/manifests/service.pp index b38537c5e..e433264be 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -4,6 +4,7 @@ $cfg_dir = '/etc/zookeeper/conf', $service_name = 'zookeeper', $service_ensure = 'running', + $manage_systemd = true, ){ require zookeeper::install @@ -18,11 +19,10 @@ default: { $initstyle = 'unknown' } } - if ($initstyle == 'systemd') { + if ($initstyle == 'systemd' and $manage_systemd == true) { file { '/usr/lib/systemd/system/zookeeper.service': ensure => 'present', content => template('zookeeper/zookeeper.service.erb'), - replace => 'no' } ~> exec { 'systemctl daemon-reload # for zookeeper': refreshonly => true, diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index 0c92458f4..55685e41c 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -40,5 +40,18 @@ :ensure => 'running', :enable => true )} + + context 'do not manage systemd' do + let(:params){{ + :manage_systemd => false, + }} + + it { should_not contain_file( + '/usr/lib/systemd/system/zookeeper.service' + ).with({ + 'ensure' => 'present', + }) + } + end end end