From 441c908184cb7428b12a5a74c650b58b9a14d8e3 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Thu, 8 Oct 2015 13:16:48 -0700 Subject: [PATCH 01/16] The zookeeper module shouldn't manage the cron package --- manifests/install.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 579a944..bc174a4 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -30,8 +30,6 @@ # if !$cleanup_count, then ensure this cron is absent. if ($snap_retain_count > 0 and $ensure != 'absent') { - ensure_packages(['cron']) - cron { 'zookeeper-cleanup': ensure => present, command => "${cleanup_sh} ${datastore} ${snap_retain_count}", From ac49050f7336eb3a73dbdecdb0d3035abef3ba68 Mon Sep 17 00:00:00 2001 From: Joseph Lynch Date: Fri, 18 Dec 2015 18:40:36 -0800 Subject: [PATCH 02/16] Add tick_time, sync_limit and init_limit to config --- manifests/config.pp | 3 +++ manifests/init.pp | 6 ++++++ templates/conf/zoo.cfg.erb | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 5ca6d05..a1f8d07 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -43,6 +43,9 @@ $rollingfile_threshold = 'ERROR', $tracefile_threshold = 'TRACE', $max_allowed_connections = 10, + $tick_time = 2000, + $init_limit = 10, + $sync_limit = 5, ) { require zookeeper::install diff --git a/manifests/init.pp b/manifests/init.pp index c07f1be..6d7154c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -39,6 +39,9 @@ $rollingfile_threshold = 'ERROR', $tracefile_threshold = 'TRACE', $max_allowed_connections = 10, + $tick_time = 2000, + $init_limit = 10, + $sync_limit = 5, ) { anchor { 'zookeeper::start': }-> @@ -69,6 +72,9 @@ rollingfile_threshold => $rollingfile_threshold, tracefile_threshold => $tracefile_threshold, max_allowed_connections => $max_allowed_connections, + tick_time => $tick_time, + init_limit => $init_limit, + sync_limit => $sync_limit, }-> class { 'zookeeper::service': cfg_dir => $cfg_dir, diff --git a/templates/conf/zoo.cfg.erb b/templates/conf/zoo.cfg.erb index e33e4bb..2bc9430 100644 --- a/templates/conf/zoo.cfg.erb +++ b/templates/conf/zoo.cfg.erb @@ -1,13 +1,13 @@ # http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html # The number of milliseconds of each tick -tickTime=2000 +tickTime=<%= scope.lookupvar('zookeeper::config::tick_time') %> # The number of ticks that the initial # synchronization phase can take -initLimit=10 +initLimit=<%= scope.lookupvar('zookeeper::config::init_limit') %> # The number of ticks that can pass between # sending a request and getting an acknowledgement -syncLimit=5 +syncLimit=<%= scope.lookupvar('zookeeper::config::sync_limit') %> # the directory where the snapshot is stored. dataDir=<%= scope.lookupvar('zookeeper::config::datastore') %> # Place the dataLogDir to a separate physical disc for better performance From 4e9fb38a06c3fb09d10fe2e2be3eb3fe9bc5aeca Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Wed, 2 Mar 2016 17:22:07 +0000 Subject: [PATCH 03/16] Add a parameter for custom log4j properties file. Many a time (such as logging to multiple files with ROLLING appender) it is a better to pass a custom file (templated higher up in modules calling this module) to which /etc/zookeeper/conf/zoo.cfg is symlinked. Also updated the spec tests. --- manifests/config.pp | 38 +++++++++++++++++++++++++++++++------ manifests/init.pp | 2 ++ spec/classes/config_spec.rb | 13 +++++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index a1f8d07..cfd41c3 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -12,6 +12,12 @@ # server.2=zookeeper2:2888:3888 # server.3=zookeeper3:2888:3888 # +# [* log4j_file *] Set to undef by default, if not full path to log4j +# properties file is required, that will be the target of symlink from +# $cfg_dir/log4j.properties. This file needs to be present and deployed +# beforehand. This is useful when one wants to template and deploy their +# own log4j properties for zookeeper logging. +# # # Actions: None # @@ -46,9 +52,17 @@ $tick_time = 2000, $init_limit = 10, $sync_limit = 5, + $log4j_file = undef, ) { require zookeeper::install + if $log4j_file { + validate_absolute_path($log4j_file) + if $log4j_file == "${cfg_dir}/log4j.properties" { + fail('log4j_file should not be same as ' + "${cfg_dir}/log4j.properties") + } + } + file { $cfg_dir: ensure => directory, owner => $user, @@ -99,12 +113,24 @@ notify => Class['zookeeper::service'], } - file { "${cfg_dir}/log4j.properties": - owner => $user, - group => $group, - mode => '0644', - content => template('zookeeper/conf/log4j.properties.erb'), - notify => Class['zookeeper::service'], + if $log4j_file { + file { "${cfg_dir}/log4j.properties": + ensure => 'link', + owner => $user, + group => $group, + mode => '0644', + target => $log4j_file, + require => File[$log4j_file], + notify => Class['zookeeper::service'], + } + } else { + file { "${cfg_dir}/log4j.properties": + owner => $user, + group => $group, + mode => '0644', + content => template('zookeeper/conf/log4j.properties.erb'), + notify => Class['zookeeper::service'], + } } } diff --git a/manifests/init.pp b/manifests/init.pp index 6d7154c..0c0ae13 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,7 @@ # interval in hours, purging enabled when >= 1 $purge_interval = 0, # log4j properties + $log4j_file = undef, $rollingfile_threshold = 'ERROR', $tracefile_threshold = 'TRACE', $max_allowed_connections = 10, @@ -75,6 +76,7 @@ tick_time => $tick_time, init_limit => $init_limit, sync_limit => $sync_limit, + log4j_file => $log4j_file, }-> class { 'zookeeper::service': cfg_dir => $cfg_dir, diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 424869e..7f59909 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -77,6 +77,19 @@ } end + context 'log4j file' do + let(:params) { { + :log4j_file => "/nail/etc/zookeeper/log4j.properties", + } } + + it do + should contain_file('/etc/zookeeper/conf/log4j.properties').with( + 'ensure' => 'link', + 'target' => log4j_file, + ) + end + end + context 'max allowed connections' do max_conn = 15 From 40f6a269c90ba6b2c107faba00ce5a6a74de3f3e Mon Sep 17 00:00:00 2001 From: Sai Sundar Raghavan Date: Fri, 8 Apr 2016 16:31:54 -0700 Subject: [PATCH 04/16] Unmanage files from dataDir and logDir --- manifests/config.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index cfd41c3..6a457fc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -75,7 +75,7 @@ ensure => directory, owner => $user, group => $group, - recurse => true, + recurse => false, mode => '0644', } @@ -84,7 +84,7 @@ owner => $user, group => $group, mode => '0644', - recurse => true, + recurse => false, } file { "${cfg_dir}/myid": From ec4803b7dacc1d5ae07f1bd52d0f53ff1bc5879d Mon Sep 17 00:00:00 2001 From: Sai Sundar Raghavan Date: Fri, 8 Apr 2016 17:24:14 -0700 Subject: [PATCH 05/16] removing the recurse option completely. --- manifests/config.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 6a457fc..ed93044 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -75,7 +75,6 @@ ensure => directory, owner => $user, group => $group, - recurse => false, mode => '0644', } @@ -84,7 +83,6 @@ owner => $user, group => $group, mode => '0644', - recurse => false, } file { "${cfg_dir}/myid": From 61a946fbd1dfd4080778e25a9dc017846a196ef6 Mon Sep 17 00:00:00 2001 From: Robert Johnson Date: Thu, 14 Sep 2017 09:04:20 -0700 Subject: [PATCH 06/16] support setting datalogstore allows users to separate the location logs are stored to the snapshots. set the template so that this change has no diff where this is not set --- manifests/config.pp | 1 + manifests/init.pp | 2 ++ templates/conf/zoo.cfg.erb | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index ed93044..a4ccf81 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -28,6 +28,7 @@ class zookeeper::config( $id = '1', $datastore = '/var/lib/zookeeper', + $datalogstore = '/var/lib/zookeeper', $client_port = 2181, $snap_count = 10000, $log_dir = '/var/log/zookeeper', diff --git a/manifests/init.pp b/manifests/init.pp index 0c0ae13..090f39b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,6 +16,7 @@ class zookeeper( $id = '1', $datastore = '/var/lib/zookeeper', + $datalogstore = '/var/lib/zookeeper', $client_port = 2181, $log_dir = '/var/log/zookeeper', $cfg_dir = '/etc/zookeeper/conf', @@ -56,6 +57,7 @@ class { 'zookeeper::config': id => $id, datastore => $datastore, + datalogstore => $datalogstore, client_port => $client_port, log_dir => $log_dir, cfg_dir => $cfg_dir, diff --git a/templates/conf/zoo.cfg.erb b/templates/conf/zoo.cfg.erb index 2bc9430..9bce572 100644 --- a/templates/conf/zoo.cfg.erb +++ b/templates/conf/zoo.cfg.erb @@ -12,7 +12,9 @@ syncLimit=<%= scope.lookupvar('zookeeper::config::sync_limit') %> dataDir=<%= scope.lookupvar('zookeeper::config::datastore') %> # Place the dataLogDir to a separate physical disc for better performance # dataLogDir=/disk2/zookeeper - +<% if scope.lookupvar('zookeeper::config::datalogstore') != scope.lookupvar('zookeeper::config:datastore') %> +dataLogDir=<%= scope.lookupvar('zookeeper::config::datalogstore') %> +<% end%> # the port at which the clients will connect clientPort=<%= scope.lookupvar('zookeeper::config::client_port') %> From 0a8b19a8f5abeec4af6825583aafcc4a1118b494 Mon Sep 17 00:00:00 2001 From: Robert Johnson Date: Thu, 14 Sep 2017 09:35:49 -0700 Subject: [PATCH 07/16] manage creation of datalogdir we only want to create the directory if its specified and its specified as someting different to datadir. if they're specified as the same dir, then no need to create anything else, since zookeeper will just use the datadir --- manifests/config.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index a4ccf81..ad92bba 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -86,6 +86,15 @@ mode => '0644', } + if $datalogstore and ($datalogstore != $datastore) { + file { $datalogstore: + ensure => directory, + owner => $user, + group => $group, + mode => '0644', + } + } + file { "${cfg_dir}/myid": ensure => file, content => template('zookeeper/conf/myid.erb'), From f79951f49306a8f84e046c2ce6278a360d0015bc Mon Sep 17 00:00:00 2001 From: Robert Johnson Date: Fri, 15 Sep 2017 06:44:42 -0700 Subject: [PATCH 08/16] default to undef for datalogstore --- manifests/config.pp | 4 ++-- manifests/init.pp | 2 +- spec/classes/config_spec.rb | 10 ++++++++++ templates/conf/zoo.cfg.erb | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index ad92bba..fe80450 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -28,7 +28,7 @@ class zookeeper::config( $id = '1', $datastore = '/var/lib/zookeeper', - $datalogstore = '/var/lib/zookeeper', + $datalogstore = undef, $client_port = 2181, $snap_count = 10000, $log_dir = '/var/log/zookeeper', @@ -86,7 +86,7 @@ mode => '0644', } - if $datalogstore and ($datalogstore != $datastore) { + if $datalogstore { file { $datalogstore: ensure => directory, owner => $user, diff --git a/manifests/init.pp b/manifests/init.pp index 090f39b..c173746 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,7 @@ class zookeeper( $id = '1', $datastore = '/var/lib/zookeeper', - $datalogstore = '/var/lib/zookeeper', + $datalogstore = undef, $client_port = 2181, $log_dir = '/var/log/zookeeper', $cfg_dir = '/etc/zookeeper/conf', diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 7f59909..eb2b670 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -101,4 +101,14 @@ '/etc/zookeeper/conf/zoo.cfg' ).with_content(/maxClientCnxns=#{max_conn}/) } end + + context 'datalogstore' do + let(:params) {{ + :datalogstore => '/tmp/log' + + }} + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).with_content(/dataLogDir=\/tmp\/log/) } + end end diff --git a/templates/conf/zoo.cfg.erb b/templates/conf/zoo.cfg.erb index 9bce572..a92d5a6 100644 --- a/templates/conf/zoo.cfg.erb +++ b/templates/conf/zoo.cfg.erb @@ -12,7 +12,7 @@ syncLimit=<%= scope.lookupvar('zookeeper::config::sync_limit') %> dataDir=<%= scope.lookupvar('zookeeper::config::datastore') %> # Place the dataLogDir to a separate physical disc for better performance # dataLogDir=/disk2/zookeeper -<% if scope.lookupvar('zookeeper::config::datalogstore') != scope.lookupvar('zookeeper::config:datastore') %> +<% if scope.lookupvar('zookeeper::config::datalogstore') %> dataLogDir=<%= scope.lookupvar('zookeeper::config::datalogstore') %> <% end%> # the port at which the clients will connect From 28680c569cf84c37aa0a130ac9ec1fc6f03ef54e Mon Sep 17 00:00:00 2001 From: Favian Ho Date: Thu, 8 Mar 2018 10:08:48 -0800 Subject: [PATCH 09/16] Add option to toggle automatic zookeeper restarts --- manifests/config.pp | 17 ++++++++++----- manifests/init.pp | 3 +++ spec/classes/config_spec.rb | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index fe80450..034576f 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -54,6 +54,7 @@ $init_limit = 10, $sync_limit = 5, $log4j_file = undef, + $restart_zookeeper = true, ) { require zookeeper::install @@ -64,6 +65,12 @@ } } + if $restart_zookeeper { + $notify_services = [Class['zookeeper::service']] + } else { + $notify_services = [] + } + file { $cfg_dir: ensure => directory, owner => $user, @@ -102,7 +109,7 @@ group => $group, mode => '0644', require => File[$cfg_dir], - notify => Class['zookeeper::service'], + notify => $notify_services, } file { "${cfg_dir}/zoo.cfg": @@ -110,7 +117,7 @@ group => $group, mode => '0644', content => template('zookeeper/conf/zoo.cfg.erb'), - notify => Class['zookeeper::service'], + notify => $notify_services, } file { "${cfg_dir}/environment": @@ -118,7 +125,7 @@ group => $group, mode => '0644', content => template('zookeeper/conf/environment.erb'), - notify => Class['zookeeper::service'], + notify => $notify_services, } if $log4j_file { @@ -129,7 +136,7 @@ mode => '0644', target => $log4j_file, require => File[$log4j_file], - notify => Class['zookeeper::service'], + notify => $notify_services, } } else { file { "${cfg_dir}/log4j.properties": @@ -137,7 +144,7 @@ group => $group, mode => '0644', content => template('zookeeper/conf/log4j.properties.erb'), - notify => Class['zookeeper::service'], + notify => $notify_services, } } diff --git a/manifests/init.pp b/manifests/init.pp index c173746..92894ea 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,6 +6,7 @@ # user # group # log_dir +# restart_zookeeper: enables automatic restarts of zookeeper after config changes # # Requires: # N/A @@ -44,6 +45,7 @@ $tick_time = 2000, $init_limit = 10, $sync_limit = 5, + $restart_zookeeper = true, ) { anchor { 'zookeeper::start': }-> @@ -79,6 +81,7 @@ init_limit => $init_limit, sync_limit => $sync_limit, log4j_file => $log4j_file, + restart_zookeeper => $restart_zookeeper, }-> class { 'zookeeper::service': cfg_dir => $cfg_dir, diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index eb2b670..6ab5f58 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -111,4 +111,46 @@ '/etc/zookeeper/conf/zoo.cfg' ).with_content(/dataLogDir=\/tmp\/log/) } end + + context 'restart zookeeper default' do + it { should contain_file( + '/etc/zookeeper/conf/myid' + ).that_notifies('Class[zookeeper::service]') } + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).that_notifies('Class[zookeeper::service]') } + it { should contain_file( + '/etc/zookeeper/conf/environment' + ).that_notifies('Class[zookeeper::service]') } + it { should contain_file( + '/etc/zookeeper/conf/log4j.properties' + ).that_notifies('Class[zookeeper::service]') } + end + + context 'restart zookeeper false' do + let(:params) {{ + :restart_zookeeper => false + + }} + it { should contain_file( + '/etc/zookeeper/conf/myid') } + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg') } + it { should contain_file( + '/etc/zookeeper/conf/environment') } + it { should contain_file( + '/etc/zookeeper/conf/log4j.properties') } + it { should_not contain_file( + '/etc/zookeeper/conf/myid' + ).that_notifies('Class[zookeeper::service]') } + it { should_not contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).that_notifies('Class[zookeeper::service]') } + it { should_not contain_file( + '/etc/zookeeper/conf/environment' + ).that_notifies('Class[zookeeper::service]') } + it { should_not contain_file( + '/etc/zookeeper/conf/log4j.properties' + ).that_notifies('Class[zookeeper::service]') } + end end From 87f2c45bd975025fc9a99c4d79691f15a4373227 Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Thu, 17 May 2018 15:42:48 +0100 Subject: [PATCH 10/16] Add xenial and systemd support. - Added unit file for zookeeper.service. - Xenial related updates. + zookeeperd not required with systemd. --- Modulefile | 1 + files/zookeeper.service | 17 +++++++++++++++++ manifests/config.pp | 24 ++++++++++++------------ manifests/install.pp | 20 ++++++++++++++++---- manifests/service.pp | 3 +-- 5 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 files/zookeeper.service diff --git a/Modulefile b/Modulefile index 2099522..ef41556 100644 --- a/Modulefile +++ b/Modulefile @@ -10,3 +10,4 @@ project_page 'https://github.com/deric/puppet-zookeeper' ## Add dependencies, if any: dependency 'puppetlabs/stdlib', '>= 0.1.6' +dependency 'camptocamp/puppet-systemd' diff --git a/files/zookeeper.service b/files/zookeeper.service new file mode 100644 index 0000000..56b6667 --- /dev/null +++ b/files/zookeeper.service @@ -0,0 +1,17 @@ +[Unit] +Description=Zookeeper distributed coordination server +After=network.target +Wants=network.target + +[Service] +User=zookeeper +Group=zookeeper +SyslogIdentifier=zookeeper +ExecStart=/bin/bash -c 'source /etc/default/zookeeper && exec /usr/share/zookeeper/bin/zkServer.sh start-foreground' +Restart=always +# This is due to zookeeper exiting with 143 when SIGTERM is sent by init. +SuccessExitStatus=143 +LimitNOFILE=120000 + +[Install] +WantedBy=multi-user.target diff --git a/manifests/config.pp b/manifests/config.pp index 034576f..c305571 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -80,25 +80,25 @@ } file { $log_dir: - ensure => directory, - owner => $user, - group => $group, - mode => '0644', + ensure => directory, + owner => $user, + group => $group, + mode => '0644', } file { $datastore: - ensure => directory, - owner => $user, - group => $group, - mode => '0644', + ensure => directory, + owner => $user, + group => $group, + mode => '0644', } if $datalogstore { file { $datalogstore: - ensure => directory, - owner => $user, - group => $group, - mode => '0644', + ensure => directory, + owner => $user, + group => $group, + mode => '0644', } } diff --git a/manifests/install.pp b/manifests/install.pp index bc174a4..9030fcc 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -23,10 +23,22 @@ ensure => $ensure } - package { ['zookeeperd']: #init.d scripts for zookeeper - ensure => $ensure, - require => Package['zookeeper'] - } + if $::lsbdistcodename == 'xenial' { + systemd::unit_file { 'zookeeper.service': + # enable/active => true is not required here since + # that also enables the automated restarted of zookeeper + # which we manage through service.pp and notify. + source => 'puppet:///modules/zookeeper/zookeeper.service', + require => Package['zookeeper'], + before => Service['zookeeper'], + } + } else { + package { ['zookeeperd']: #init.d scripts for zookeeper + ensure => $ensure, + require => Package['zookeeper'], + before => Service['zookeeper'], + } + } # if !$cleanup_count, then ensure this cron is absent. if ($snap_retain_count > 0 and $ensure != 'absent') { diff --git a/manifests/service.pp b/manifests/service.pp index e24fc23..f97c273 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -11,8 +11,7 @@ hasrestart => true, enable => true, require => [ - Package['zookeeperd'], File["${cfg_dir}/zoo.cfg"] ] } -} \ No newline at end of file +} From 8fef2a9f3d5b002e3c88a557b7983916b0b661e4 Mon Sep 17 00:00:00 2001 From: Raghavendra Prabhu Date: Thu, 7 Jun 2018 10:11:50 -0700 Subject: [PATCH 11/16] Fix rspec tests and rake. Also fix the restarting of zookeeper service when files are changed. There was a dependency loop which meant that if restart_zookeeper were true, the notify was being set up before service was actually defined. Bunch of minor fixes. --- Gemfile | 17 +-- Gemfile.lock | 200 +++++++++++++++++------------------ Rakefile | 5 +- manifests/config.pp | 14 +-- manifests/init.pp | 2 +- manifests/install.pp | 2 - manifests/service.pp | 11 ++ spec/classes/config_spec.rb | 57 ++-------- spec/classes/install_spec.rb | 8 +- spec/classes/service_spec.rb | 43 ++++++++ 10 files changed, 180 insertions(+), 179 deletions(-) diff --git a/Gemfile b/Gemfile index 5d48d5c..8175c8a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,14 @@ source 'https://rubygems.org' -gem 'puppet', '>= 2.7.0' -gem 'puppet-lint', '>=0.3.2' -gem 'puppetlabs_spec_helper', '>=0.2.0' -gem 'rake', '>=0.9.2.2' +gem 'puppet', '4.5.3' +gem 'puppet-lint', '2.0.2' +gem 'puppetlabs_spec_helper', '~> 1.1.0' +gem 'rake', '11.1.1' +gem 'rake-hooks', '1.2.3' gem 'librarian-puppet', '>=0.9.10' -gem 'rspec-system-puppet', :require => false -gem 'serverspec', :require => false -gem 'rspec-system-serverspec', :require => false gem 'hiera-puppet-helper', :git => 'https://github.com/mmz-srf/hiera-puppet-helper.git' gem 'puppet-blacksmith', :git => 'https://github.com/maestrodev/puppet-blacksmith.git' -gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git' + +gem 'rspec', '~> 3.4.0' # MIT +gem 'rspec-core', '~> 3.4.4' # MIT +gem 'rspec-puppet', '2.6.10' # MIT diff --git a/Gemfile.lock b/Gemfile.lock index 7e4d939..cbcc5a3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,9 @@ GIT remote: https://github.com/maestrodev/puppet-blacksmith.git - revision: adeb613d78dc1e9971ad175ecd5d3b66465ba927 + revision: d62d39dac4620cf4542a10cbba7328555726dc7d specs: - puppet-blacksmith (2.0.2) - nokogiri - puppet (>= 2.7.16) - rest-client + puppet-blacksmith (4.1.2) + rest-client (~> 2.0) GIT remote: https://github.com/mmz-srf/hiera-puppet-helper.git @@ -13,101 +11,96 @@ GIT specs: hiera-puppet-helper (2.0.1) -GIT - remote: https://github.com/rodjek/rspec-puppet.git - revision: 03e94422fb9bbdd950d5a0bec6ead5d76e06616b - specs: - rspec-puppet (1.0.1) - rspec - GEM remote: https://rubygems.org/ specs: - builder (3.2.2) - diff-lcs (1.2.5) - excon (0.31.0) - facter (1.7.4) - fog (1.19.0) - builder - excon (~> 0.31.0) - formatador (~> 0.2.0) - mime-types - multi_json (~> 1.0) - net-scp (~> 1.1) - net-ssh (>= 2.1.3) - nokogiri (~> 1.5) - ruby-hmac - formatador (0.2.4) - hiera (1.3.1) - json_pure - highline (1.6.20) - json (1.8.1) - json_pure (1.8.1) - kwalify (0.7.2) - librarian-puppet (0.9.10) - json + CFPropertyList (2.2.8) + diff-lcs (1.3) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + facter (2.5.1) + CFPropertyList (~> 2.2) + faraday (0.13.1) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.12.2) + faraday (>= 0.7.4, < 1.0) + fast_gettext (1.1.2) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.30) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + hiera (3.4.3) + http-cookie (1.0.3) + domain_name (~> 0.5) + json_pure (2.1.0) + librarian-puppet (3.0.0) + librarianp (>= 0.6.3) + puppet_forge (~> 2.1) + rsync + librarianp (0.6.4) thor (~> 0.15) - metaclass (0.0.2) - mime-types (1.25.1) - mocha (1.0.0) + locale (2.1.2) + metaclass (0.0.4) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + minitar (0.6.1) + mocha (1.5.0) metaclass (~> 0.0.1) - multi_json (1.8.4) - net-scp (1.1.2) - net-ssh (>= 2.6.5) - net-ssh (2.7.0) - nokogiri (1.5.11) - puppet (3.4.2) - facter (~> 1.6) - hiera (~> 1.0) - rgen (~> 0.6.5) - puppet-lint (0.3.2) - puppetlabs_spec_helper (0.4.1) - mocha (>= 0.10.5) + multipart-post (2.0.0) + netrc (0.11.0) + puppet (4.5.3) + CFPropertyList (~> 2.2.6) + facter (> 2.0, < 4) + hiera (>= 2.0, < 4) + json_pure + puppet-lint (2.0.2) + puppet-syntax (2.4.1) + rake + puppet_forge (2.2.9) + faraday (>= 0.9.0, < 0.14.0) + faraday_middleware (>= 0.9.0, < 0.13.0) + gettext-setup (~> 0.11) + minitar + semantic_puppet (~> 1.0) + puppetlabs_spec_helper (1.1.1) + mocha + puppet-lint + puppet-syntax + rake + rspec-puppet + rake (11.1.1) + rake-hooks (1.2.3) rake - rspec (>= 2.9.0) - rspec-puppet (>= 0.1.1) - rake (10.1.1) - rbvmomi (1.8.1) - builder - nokogiri (>= 1.4.1) - trollop - rest-client (1.6.7) - mime-types (>= 1.16) - rgen (0.6.6) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.7) - rspec-expectations (2.14.4) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.4) - rspec-system (2.8.0) - fog (~> 1.18) - kwalify (~> 0.7.2) - mime-types (~> 1.16) - net-scp (~> 1.1) - net-ssh (~> 2.7) - nokogiri (~> 1.5.10) - rbvmomi (~> 1.6) - rspec (~> 2.14) - systemu (~> 2.5) - rspec-system-puppet (2.2.1) - rspec-system (~> 2.0) - rspec-system-serverspec (2.0.1) - rspec-system (~> 2.0) - serverspec (~> 0.0) - specinfra (~> 0.0) - ruby-hmac (0.4.0) - serverspec (0.14.4) - highline - net-ssh - rspec (>= 2.13.0) - specinfra (>= 0.1.0) - specinfra (0.4.1) - systemu (2.6.0) - thor (0.18.1) - trollop (2.0) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.4) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-puppet (2.6.10) + rspec + rspec-support (3.4.1) + rsync (1.0.9) + semantic_puppet (1.0.2) + text (1.3.1) + thor (0.20.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) PLATFORMS ruby @@ -115,12 +108,15 @@ PLATFORMS DEPENDENCIES hiera-puppet-helper! librarian-puppet (>= 0.9.10) - puppet (>= 2.7.0) + puppet (= 4.5.3) puppet-blacksmith! - puppet-lint (>= 0.3.2) - puppetlabs_spec_helper (>= 0.2.0) - rake (>= 0.9.2.2) - rspec-puppet! - rspec-system-puppet - rspec-system-serverspec - serverspec + puppet-lint (= 2.0.2) + puppetlabs_spec_helper (~> 1.1.0) + rake (= 11.1.1) + rake-hooks (= 1.2.3) + rspec (~> 3.4.0) + rspec-core (~> 3.4.4) + rspec-puppet (= 2.6.10) + +BUNDLED WITH + 1.12.5 diff --git a/Rakefile b/Rakefile index f8ccea6..d7d579a 100644 --- a/Rakefile +++ b/Rakefile @@ -2,12 +2,13 @@ require 'bundler' Bundler.require(:rake) require 'puppet-lint/tasks/puppet-lint' -require 'rspec-system/rake_task' require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet_blacksmith/rake_tasks' +require 'rake/dsl_definition' +require 'rake/hooks' -PuppetLint.configuration.ignore_paths = ["spec/fixtures/modules/cron/manifests/*.pp"] +PuppetLint.configuration.ignore_paths = ["spec/fixtures/modules/cron/manifests/*.pp", "vendor/**/*"] PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}' PuppetLint.configuration.send("disable_80chars") diff --git a/manifests/config.pp b/manifests/config.pp index c305571..a5a8583 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -54,7 +54,6 @@ $init_limit = 10, $sync_limit = 5, $log4j_file = undef, - $restart_zookeeper = true, ) { require zookeeper::install @@ -65,12 +64,6 @@ } } - if $restart_zookeeper { - $notify_services = [Class['zookeeper::service']] - } else { - $notify_services = [] - } - file { $cfg_dir: ensure => directory, owner => $user, @@ -109,7 +102,6 @@ group => $group, mode => '0644', require => File[$cfg_dir], - notify => $notify_services, } file { "${cfg_dir}/zoo.cfg": @@ -117,7 +109,7 @@ group => $group, mode => '0644', content => template('zookeeper/conf/zoo.cfg.erb'), - notify => $notify_services, + require => File[$cfg_dir], } file { "${cfg_dir}/environment": @@ -125,7 +117,7 @@ group => $group, mode => '0644', content => template('zookeeper/conf/environment.erb'), - notify => $notify_services, + require => File[$cfg_dir], } if $log4j_file { @@ -136,7 +128,6 @@ mode => '0644', target => $log4j_file, require => File[$log4j_file], - notify => $notify_services, } } else { file { "${cfg_dir}/log4j.properties": @@ -144,7 +135,6 @@ group => $group, mode => '0644', content => template('zookeeper/conf/log4j.properties.erb'), - notify => $notify_services, } } diff --git a/manifests/init.pp b/manifests/init.pp index 92894ea..03ff058 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -81,10 +81,10 @@ init_limit => $init_limit, sync_limit => $sync_limit, log4j_file => $log4j_file, - restart_zookeeper => $restart_zookeeper, }-> class { 'zookeeper::service': cfg_dir => $cfg_dir, + restart_zookeeper => $restart_zookeeper, } -> anchor { 'zookeeper::end': } diff --git a/manifests/install.pp b/manifests/install.pp index 9030fcc..af1d547 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -30,13 +30,11 @@ # which we manage through service.pp and notify. source => 'puppet:///modules/zookeeper/zookeeper.service', require => Package['zookeeper'], - before => Service['zookeeper'], } } else { package { ['zookeeperd']: #init.d scripts for zookeeper ensure => $ensure, require => Package['zookeeper'], - before => Service['zookeeper'], } } diff --git a/manifests/service.pp b/manifests/service.pp index f97c273..fbe04e1 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -2,8 +2,12 @@ class zookeeper::service( $cfg_dir = '/etc/zookeeper/conf', + $restart_zookeeper = true, ){ require zookeeper::install + require zookeeper::config + validate_bool($restart_zookeeper) + service { 'zookeeper': ensure => 'running', @@ -14,4 +18,11 @@ File["${cfg_dir}/zoo.cfg"] ] } + + if $restart_zookeeper { + File["${cfg_dir}/myid"] ~> Service['zookeeper'] + File["${cfg_dir}/zoo.cfg"] ~> Service['zookeeper'] + File["${cfg_dir}/environment"] ~> Service['zookeeper'] + File["${cfg_dir}/log4j.properties"] ~> Service['zookeeper'] + } } diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 6ab5f58..04db9c2 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -4,7 +4,7 @@ shared_examples 'debian-install' do |os, codename| let(:facts) {{ :operatingsystem => os, - :osfamily => 'Debian', + :osfamily => 'Ubuntu', :lsbdistcodename => codename, }} @@ -26,6 +26,11 @@ 'group' => group, }).with_content(myid) } + it { should contain_file(env_file).with({ + 'owner' => user, + 'group' => group, + }).with_content(/NAME=zookeeper/) } + end context 'on debian-like system' do @@ -34,9 +39,10 @@ let(:cfg_dir) { '/etc/zookeeper/conf' } let(:log_dir) { '/var/lib/zookeeper' } let(:id_file) { '/etc/zookeeper/conf/myid' } + let(:env_file) { '/etc/zookeeper/conf/environment' } let(:myid) { /1/ } - it_behaves_like 'debian-install', 'Debian', 'wheezy' + it_behaves_like 'debian-install', 'Ubuntu', 'trusty' end context 'custom parameters' do @@ -56,8 +62,9 @@ let(:log_dir) { '/var/lib/zookeeper/log' } let(:id_file) { '/var/lib/zookeeper/conf/myid' } let(:myid) { /2/ } + let(:env_file) { '/var/lib/zookeeper/conf/environment' } - it_behaves_like 'debian-install', 'Debian', 'wheezy' + it_behaves_like 'debian-install', 'Ubuntu', 'trusty' end context 'extra parameters' do @@ -85,7 +92,7 @@ it do should contain_file('/etc/zookeeper/conf/log4j.properties').with( 'ensure' => 'link', - 'target' => log4j_file, + 'target' => '/nail/etc/zookeeper/log4j.properties', ) end end @@ -111,46 +118,4 @@ '/etc/zookeeper/conf/zoo.cfg' ).with_content(/dataLogDir=\/tmp\/log/) } end - - context 'restart zookeeper default' do - it { should contain_file( - '/etc/zookeeper/conf/myid' - ).that_notifies('Class[zookeeper::service]') } - it { should contain_file( - '/etc/zookeeper/conf/zoo.cfg' - ).that_notifies('Class[zookeeper::service]') } - it { should contain_file( - '/etc/zookeeper/conf/environment' - ).that_notifies('Class[zookeeper::service]') } - it { should contain_file( - '/etc/zookeeper/conf/log4j.properties' - ).that_notifies('Class[zookeeper::service]') } - end - - context 'restart zookeeper false' do - let(:params) {{ - :restart_zookeeper => false - - }} - it { should contain_file( - '/etc/zookeeper/conf/myid') } - it { should contain_file( - '/etc/zookeeper/conf/zoo.cfg') } - it { should contain_file( - '/etc/zookeeper/conf/environment') } - it { should contain_file( - '/etc/zookeeper/conf/log4j.properties') } - it { should_not contain_file( - '/etc/zookeeper/conf/myid' - ).that_notifies('Class[zookeeper::service]') } - it { should_not contain_file( - '/etc/zookeeper/conf/zoo.cfg' - ).that_notifies('Class[zookeeper::service]') } - it { should_not contain_file( - '/etc/zookeeper/conf/environment' - ).that_notifies('Class[zookeeper::service]') } - it { should_not contain_file( - '/etc/zookeeper/conf/log4j.properties' - ).that_notifies('Class[zookeeper::service]') } - end end diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index 8d938a9..44d1807 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -10,7 +10,6 @@ it { should contain_package('zookeeper') } it { should contain_package('zookeeperd') } - it { should contain_package('cron') } it { should contain_cron('zookeeper-cleanup').with({ @@ -30,11 +29,10 @@ let(:params) { { :snap_retain_count => 1, + :ensure => 'present', } } - it_behaves_like 'debian-install', 'Debian', 'squeeze' - it_behaves_like 'debian-install', 'Debian', 'wheezy' - it_behaves_like 'debian-install', 'Ubuntu', 'precise' + it_behaves_like 'debian-install', 'Ubuntu', 'trusty' end context 'without cron' do @@ -47,7 +45,6 @@ it { should contain_package('zookeeper') } it { should contain_package('zookeeperd') } - it { should_not contain_package('cron') } end @@ -70,7 +67,6 @@ 'ensure' => 'absent', }) } - it { should_not contain_package('cron') } end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index f7787ff..dd6f2f3 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -12,4 +12,47 @@ :ensure => 'running', :enable => true )} + + + context 'restart zookeeper default' do + it { should contain_file( + '/etc/zookeeper/conf/myid' + ).that_notifies('Service[zookeeper]') } + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).that_notifies('Service[zookeeper]') } + it { should contain_file( + '/etc/zookeeper/conf/environment' + ).that_notifies('Service[zookeeper]') } + it { should contain_file( + '/etc/zookeeper/conf/log4j.properties' + ).that_notifies('Service[zookeeper]') } + end + + context 'restart zookeeper false' do + let(:params) {{ + :restart_zookeeper => false + + }} + it { should contain_file( + '/etc/zookeeper/conf/myid') } + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg') } + it { should contain_file( + '/etc/zookeeper/conf/environment') } + it { should contain_file( + '/etc/zookeeper/conf/log4j.properties') } + it { should_not contain_file( + '/etc/zookeeper/conf/myid' + ).that_notifies('Service[zookeeper]') } + it { should_not contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).that_notifies('Service[zookeeper]') } + it { should_not contain_file( + '/etc/zookeeper/conf/environment' + ).that_notifies('Service[zookeeper]') } + it { should_not contain_file( + '/etc/zookeeper/conf/log4j.properties' + ).that_notifies('Service[zookeeper]') } + end end From ef5b0db6f9c3fdf5d3d1cb86f07f9ead860b083b Mon Sep 17 00:00:00 2001 From: Raghavendra Prabhu Date: Fri, 8 Jun 2018 07:39:11 -0700 Subject: [PATCH 12/16] Lint fixes --- manifests/init.pp | 16 ++++++---------- manifests/install.pp | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 03ff058..07f3256 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -48,15 +48,14 @@ $restart_zookeeper = true, ) { - anchor { 'zookeeper::start': }-> - class { 'zookeeper::install': + anchor { 'zookeeper::start': } + -> class { 'zookeeper::install': ensure => $ensure, snap_retain_count => $snap_retain_count, datastore => $datastore, user => $user, cleanup_sh => $cleanup_sh, - }-> - class { 'zookeeper::config': + } -> class { 'zookeeper::config': id => $id, datastore => $datastore, datalogstore => $datalogstore, @@ -81,12 +80,9 @@ init_limit => $init_limit, sync_limit => $sync_limit, log4j_file => $log4j_file, - }-> - class { 'zookeeper::service': - cfg_dir => $cfg_dir, + }-> class { 'zookeeper::service': + cfg_dir => $cfg_dir, restart_zookeeper => $restart_zookeeper, - } - -> - anchor { 'zookeeper::end': } + } -> anchor { 'zookeeper::end': } } diff --git a/manifests/install.pp b/manifests/install.pp index af1d547..07f645c 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -36,7 +36,7 @@ ensure => $ensure, require => Package['zookeeper'], } - } + } # if !$cleanup_count, then ensure this cron is absent. if ($snap_retain_count > 0 and $ensure != 'absent') { From c225854bf48f0a442ea892407b4b44a9a33bdcda Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Wed, 13 Jun 2018 12:52:11 +0100 Subject: [PATCH 13/16] Update travis.yml --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bd2a2b..f8e6911 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,22 +2,14 @@ before_install: - gem update --system 2.1.11 - gem --version rvm: - - 1.8.7 - - 1.9.3 - 2.0.0 + - 2.1.0 script: 'bundle exec rake spec' env: - - PUPPET_VERSION="~> 2.7.0" - - PUPPET_VERSION="~> 3.0.0" - - PUPPET_VERSION="~> 3.1.0" - - PUPPET_VERSION="~> 3.2.0" - - PUPPET_VERSION="~> 3.3.0" - PUPPET_VERSION="~> 3.4.0" + - PUPPET_VERSION="~> 4.3.0" matrix: exclude: - # No support for Ruby 1.9 before Puppet 2.7 - - rvm: 1.9.3 - env: PUPPET_VERSION=2.6.0 # No support for Ruby 2.0 before Puppet 3.2 - rvm: 2.0.0 env: PUPPET_VERSION="~> 2.7.0" From 252cdef2b0cb1e2adbacdcfafcd2af5ede063727 Mon Sep 17 00:00:00 2001 From: Avadhut Phatarpekar Date: Tue, 26 Feb 2019 02:00:51 -0800 Subject: [PATCH 14/16] Enable quorumListenOnAllIPs in zoo.cfg --- templates/conf/zoo.cfg.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/conf/zoo.cfg.erb b/templates/conf/zoo.cfg.erb index a92d5a6..7c95bb9 100644 --- a/templates/conf/zoo.cfg.erb +++ b/templates/conf/zoo.cfg.erb @@ -66,3 +66,7 @@ autopurge.purgeInterval=<%= scope.lookupvar('zookeeper::config::purge_interval') # Maximum allowed connections maxClientCnxns=<%= scope.lookupvar('zookeeper::config::max_allowed_connections') %> + +# Listen for connections from peers on all available IPs +# Default is false; but, at Yelp, via Puppet the default is set to true +quorumListenOnAllIPs=<%= scope.lookupvar('zookeeper::config::quorum_listen_on_all_ips') %> From 741c2bfd8c5f970136277f4f5096332131c10132 Mon Sep 17 00:00:00 2001 From: Avadhut Phatarpekar Date: Tue, 26 Feb 2019 03:34:42 -0800 Subject: [PATCH 15/16] Doh! Forgot to allow the puppet class to pass the config. Also, now, added tests. --- manifests/config.pp | 1 + manifests/init.pp | 50 +++++++++++++++++++------------------ spec/classes/config_spec.rb | 12 +++++++++ 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index a5a8583..64d61db 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -50,6 +50,7 @@ $rollingfile_threshold = 'ERROR', $tracefile_threshold = 'TRACE', $max_allowed_connections = 10, + $quorum_listen_on_all_ips = true, $tick_time = 2000, $init_limit = 10, $sync_limit = 5, diff --git a/manifests/init.pp b/manifests/init.pp index 07f3256..8a8fd7c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,6 +42,7 @@ $rollingfile_threshold = 'ERROR', $tracefile_threshold = 'TRACE', $max_allowed_connections = 10, + $quorum_listen_on_all_ips = true, $tick_time = 2000, $init_limit = 10, $sync_limit = 5, @@ -56,30 +57,31 @@ user => $user, cleanup_sh => $cleanup_sh, } -> class { 'zookeeper::config': - id => $id, - datastore => $datastore, - datalogstore => $datalogstore, - client_port => $client_port, - log_dir => $log_dir, - cfg_dir => $cfg_dir, - user => $user, - group => $group, - java_bin => $java_bin, - java_opts => $java_opts, - pid_dir => $pid_dir, - zoo_main => $zoo_main, - log4j_prop => $log4j_prop, - servers => $servers, - snap_count => $snap_count, - snap_retain_count => $snap_retain_count, - purge_interval => $purge_interval, - rollingfile_threshold => $rollingfile_threshold, - tracefile_threshold => $tracefile_threshold, - max_allowed_connections => $max_allowed_connections, - tick_time => $tick_time, - init_limit => $init_limit, - sync_limit => $sync_limit, - log4j_file => $log4j_file, + id => $id, + datastore => $datastore, + datalogstore => $datalogstore, + client_port => $client_port, + log_dir => $log_dir, + cfg_dir => $cfg_dir, + user => $user, + group => $group, + java_bin => $java_bin, + java_opts => $java_opts, + pid_dir => $pid_dir, + zoo_main => $zoo_main, + log4j_prop => $log4j_prop, + servers => $servers, + snap_count => $snap_count, + snap_retain_count => $snap_retain_count, + purge_interval => $purge_interval, + rollingfile_threshold => $rollingfile_threshold, + tracefile_threshold => $tracefile_threshold, + max_allowed_connections => $max_allowed_connections, + quorum_listen_on_all_ips => $quorum_listen_on_all_ips, + tick_time => $tick_time, + init_limit => $init_limit, + sync_limit => $sync_limit, + log4j_file => $log4j_file, }-> class { 'zookeeper::service': cfg_dir => $cfg_dir, restart_zookeeper => $restart_zookeeper, diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 04db9c2..2cb22bf 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -109,6 +109,18 @@ ).with_content(/maxClientCnxns=#{max_conn}/) } end + context 'quorum listen on all ips' do + quorum_listen_on_all_ips = false + + let(:params) {{ + :quorum_listen_on_all_ips => quorum_listen_on_all_ips + }} + + it { should contain_file( + '/etc/zookeeper/conf/zoo.cfg' + ).with_content(/quorumListenOnAllIPs=#{quorum_listen_on_all_ips}/) } + end + context 'datalogstore' do let(:params) {{ :datalogstore => '/tmp/log' From a9d61f54154c146c8597eea16b3398225558ae96 Mon Sep 17 00:00:00 2001 From: Avadhut Phatarpekar Date: Tue, 26 Feb 2019 03:55:35 -0800 Subject: [PATCH 16/16] Validate quorum_listen_on_all_ips as a boolean --- manifests/init.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 8a8fd7c..75ad2ae 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,6 +49,8 @@ $restart_zookeeper = true, ) { + validate_bool($quorum_listen_on_all_ips) + anchor { 'zookeeper::start': } -> class { 'zookeeper::install': ensure => $ensure,