Skip to content

Commit

Permalink
optionally manage service, alternative solution to redhat-openstack#26,
Browse files Browse the repository at this point in the history
redhat-openstack#31

Right now there's no possibility to enforce service configuration
on RHEL7. This might be changed in future.
  • Loading branch information
deric committed Sep 16, 2015
1 parent 3365261 commit 2750d55
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ This is a workaround for a a [Facter issue](https://tickets.puppetlabs.com/brows

- `id` - cluster-unique zookeeper's instance id (1-255)
- `datastore`
- `datalogstore` - specifying this configures the dataLogDir Zookeeper config values and allows for transaction logs to be stored in a different location, improving IO performance
- `datalogstore` - specifying this configures the dataLogDir ZooKeeper config values and allows for transaction logs to be stored in a different location, improving IO performance
- `log_dir`
- `purge_interval` - automatically will delete zookeeper logs (available since 3.4.0)
- `snap_retain_count` - number of snapshots that will be kept after purging (since 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 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 3.3.0)
- `purge_interval` - automatically will delete zookeeper logs (available since ZooKeeper 3.4.0)
- `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

and many others, see the `init.pp` file for more details.

Expand Down
18 changes: 11 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
$java_package = undef,
$min_session_timeout = undef,
$max_session_timeout = undef,
$manage_systemd = true,
$manage_service = true,
) {

validate_array($packages)
validate_bool($ensure_cron)
validate_bool($manage_systemd)
validate_bool($manage_service)

anchor { 'zookeeper::start': }->
class { 'zookeeper::install':
Expand Down Expand Up @@ -108,12 +108,16 @@
peer_type => $peer_type,
min_session_timeout => $min_session_timeout,
max_session_timeout => $max_session_timeout,
}->
class { 'zookeeper::service':
cfg_dir => $cfg_dir,
service_name => $service_name,
}
->

if ($manage_service) {
class { 'zookeeper::service':
cfg_dir => $cfg_dir,
service_name => $service_name,
require => Class['zookeeper::config'],
before => Anchor['zookeeper::end'],
}
}
anchor { 'zookeeper::end': }

}
4 changes: 2 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
default: { $initstyle = 'unknown' }
}

if ($initstyle == 'systemd' and $zookeeper::manage_systemd) {
if ($initstyle == 'systemd') {
file { '/usr/lib/systemd/system/zookeeper.service':
ensure => 'present',
content => template('zookeeper/zookeeper.service.erb'),
replace => "no"
replace => 'no'
} ~>
exec { 'systemctl daemon-reload # for zookeeper':
refreshonly => true,
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@
'/etc/zookeeper/conf/zoo.cfg'
).with_content(/maxSessionTimeout=60000/) }
end

context 'disable service management' do
let(:user) { 'zookeeper' }
let(:group) { 'zookeeper' }

let(:params) { {
:manage_service => false,
} }

it { should contain_package('zookeeper').with({:ensure => 'present'}) }
it { should_not contain_service('zookeeper').with({:ensure => 'running'}) }
it { should_not contain_class('zookeeper::service') }
end
end

0 comments on commit 2750d55

Please sign in to comment.