diff --git a/README.md b/README.md index 925cda0..ecbd1e2 100644 --- a/README.md +++ b/README.md @@ -117,9 +117,7 @@ class { 'zookeeper': Some reasonable values are: - * `init` - RHEL6, Debian 7 - * `upstart` - Ubuntu - * `systemd` - RHEL 7, Debian 8 + * `systemd` * `runit` * `exhibitor` - zookeeper process and config will be managed by exhibitor (https://github.com/soabase/exhibitor). Exhibitor is not managed by this module. * `none` - service won't be installed @@ -371,12 +369,11 @@ rake beaker:sets ## Supported platforms * Debian/Ubuntu - * Debian 6 Squeeze: you can get ZooKeeper package from [Wheezy](http://packages.debian.org/wheezy/zookeeper) or [Sid](http://packages.debian.org/sid/zookeeper) repo. - * Debian 7 Wheezy: available in apt repository * RedHat/CentOS/Fedora ### Tested on: - * Debian 6 - Squeeze, 7 - Wheezy, 8 - Jessie - * Ubuntu 12.04.03 LTS, 14.04 - * RHEL 6, RHEL 7, CentOS 6 + * Debian (8, 9, 10) + * Ubuntu (16.04, 18.04) + * RHEL (6, 7) + * CentOS (6, 7) diff --git a/manifests/params.pp b/manifests/params.pp index bc116e6..8066948 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -13,19 +13,8 @@ case $os_family { 'Debian': { case $os_name { - 'Debian': { - if versioncmp($os_release, '8') < 0 { - $initstyle = 'init' - } else { - $initstyle = 'systemd' - } - } - 'Ubuntu': { - if versioncmp($os_release, '15.04') < 0 { - $initstyle = 'upstart' - } else { - $initstyle = 'systemd' - } + 'Debian', 'Ubuntu': { + $initstyle = 'systemd' } default: { $initstyle = undef } } @@ -42,19 +31,8 @@ } 'RedHat': { case $os_name { - 'RedHat': { - if versioncmp($os_release, '7') < 0 { - $initstyle = 'redhat' - } else { - $initstyle = 'systemd' - } - } - 'CentOS' : { - if versioncmp($os_release, '7') < 0 { - $initstyle = 'redhat' - } else { - $initstyle = 'systemd' - } + 'RedHat', 'CentOS': { + $initstyle = 'systemd' } default: { $initstyle = undef diff --git a/manifests/post_install.pp b/manifests/post_install.pp index 2186306..e88ae45 100644 --- a/manifests/post_install.pp +++ b/manifests/post_install.pp @@ -18,19 +18,8 @@ case $os_family { 'Debian': { case $os_name { - 'Debian': { - if versioncmp($os_release, '8') < 0 { # 3.3.5 - $_clean = true - } else { # future releases - $_clean = false - } - } - 'Ubuntu': { - if versioncmp($os_release, '12.04') < 0 { # 3.3.5 - $_clean = true - } else { # future releases - $_clean = false - } + 'Debian', 'Ubuntu': { + $_clean = false } default: { fail ("Family: '${os_family}' OS: '${os_name}' is not supported yet") diff --git a/manifests/service.pp b/manifests/service.pp index 326d168..a653ff4 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -16,28 +16,14 @@ } if $::zookeeper::manage_service_file == true { - if $::zookeeper::service_provider == 'systemd' { - file { "${::zookeeper::systemd_path}/${::zookeeper::service_name}.service": - ensure => 'present', - content => template("${module_name}/zookeeper.service.erb"), - } - ~> exec { 'systemctl daemon-reload # for zookeeper': - refreshonly => true, - path => $::path, - notify => Service[$::zookeeper::service_name], - } - } elsif ( - $::zookeeper::service_provider == 'init' - or $::zookeeper::service_provider == 'redhat' - or $::zookeeper::service_provider == 'debian' - ) { - file { "/etc/init.d/${::zookeeper::service_name}": - ensure => present, - content => template("${module_name}/zookeeper.${facts['os']['family']}.init.erb"), - mode => '0755', - before => Service[$::zookeeper::service_name], - notify => Service[$::zookeeper::service_name], - } + file { "${::zookeeper::systemd_path}/${::zookeeper::service_name}.service": + ensure => 'present', + content => template("${module_name}/zookeeper.service.erb"), + } + ~> exec { 'systemctl daemon-reload # for zookeeper': + refreshonly => true, + path => $::path, + notify => Service[$::zookeeper::service_name], } } diff --git a/metadata.json b/metadata.json index a5b96b8..3443b9b 100644 --- a/metadata.json +++ b/metadata.json @@ -44,8 +44,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "6", - "7", "8", "9", "10" @@ -54,8 +52,6 @@ { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "12.04", - "14.04", "16.04", "18.04" ] diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index d6e70e9..ef90b88 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -178,48 +178,6 @@ it { is_expected.to contain_user('zookeeper').with({:ensure => 'present'}) } end - context 'set pid file for init provider' do - let(:params) do - { - :zoo_dir => '/usr/lib/zookeeper', - :log_dir => '/var/log/zookeeper', - :manage_service => true, - :manage_service_file => true, - :service_provider => 'init', - } - end - - it do - is_expected.to contain_file( - '/etc/zookeeper/conf/log4j.properties' - ).with_content(/zookeeper.log.dir=\/var\/log\/zookeeper/) - end - - context 'set service provider' do - it { is_expected.to contain_package('zookeeper').with({:ensure => 'present'}) } - it do - is_expected.to contain_service(service_name).with({ - :ensure => 'running', - :provider => 'init', - }) - end - end - - if os_facts[:osfamily] == 'RedHat' - it do - is_expected.to contain_file( - "/etc/init.d/#{service_name}" - ).with_content(/pidfile=\/var\/run\/zookeeper.pid/) - end - else - it do - is_expected.to contain_file( - environment_file - ).with_content(/PIDFILE=\/var\/run\/zookeeper.pid/) - end - end - end - context 'create env file' do it do is_expected.to contain_file( diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index 727e6b3..1eb5a32 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -125,36 +125,7 @@ end end end - when 'init' - context 'init' do - let :pre_condition do - 'class {"zookeeper": - zoo_dir => "/usr/lib/zookeeper", - log_dir => "/var/log/zookeeper", - manage_service_file => true, - service_provider => "init", - }' - end - - it do - is_expected.to contain_file( - '/etc/init.d/zookeeper' - ).with({ - 'ensure' => 'present', - }) - end - - it do - is_expected.to contain_service('zookeeper').with( - :ensure => 'running', - :enable => true, - :provider => 'init', - ) - end - end - end - if init_provider != 'upstart' context 'custom service name' do let :pre_condition do 'class {"zookeeper": diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index 92523bb..d5c1d20 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -16,64 +16,17 @@ def get_os_info(facts) info[:environment_file] = '/etc/zookeeper/conf/environment' info[:should_install_zookeeperd] = true info[:zookeeper_shell] = '/bin/false' - - case facts[:os]['name'] - when 'Debian' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') < 0 - info[:init_provider] = 'init' - info[:should_install_cron] = true - else - info[:init_provider] = 'systemd' - end - when 'Ubuntu' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '15.04') < 0 - info[:init_provider] = 'upstart' - else - info[:init_provider] = 'systemd' - end - - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '12.04') < 0 - info[:should_install_cron] = true - end - end + info[:init_provider] = 'systemd' when 'RedHat' info[:service_name] = 'zookeeper-server' info[:environment_file] = '/etc/zookeeper/conf/java.env' info[:should_install_zookeeperd] = false info[:zookeeper_shell] = '/sbin/nologin' - - case facts[:os]['name'] - when 'RedHat' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '7') < 0 - info[:init_provider] = 'redhat' - else - info[:init_provider] = 'systemd' - end - when 'CentOS' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '7') < 0 - info[:init_provider] = 'redhat' - else - info[:init_provider] = 'systemd' - end - end + info[:init_provider] = 'systemd' end - case info[:init_provider] - when 'init' - info[:init_dir] = '/etc/init.d' - when 'systemd' - info[:init_dir] = '/etc/systemd/system' - when 'upstart' - info[:init_dir] = '/etc/init' - when 'redhat' - info[:init_dir] = '/etc/init.d' - end - - if info[:init_provider] == 'systemd' - info[:service_file] = "#{info[:init_dir]}/#{info[:service_name]}.service" - else - info[:service_file] = "#{info[:init_dir]}/#{info[:service_name]}" - end + info[:init_dir] = '/etc/systemd/system' + info[:service_file] = "#{info[:init_dir]}/#{info[:service_name]}.service" return info end diff --git a/templates/zookeeper.Debian.init.erb b/templates/zookeeper.Debian.init.erb deleted file mode 100644 index 00cfe98..0000000 --- a/templates/zookeeper.Debian.init.erb +++ /dev/null @@ -1,187 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: zookeeper -# Required-Start: $remote_fs -# Required-Stop: $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: centralized coordination service -# Description: ZooKeeper is a centralized service for maintaining -# configuration information, naming, providing distributed -# synchronization, and providing group services. -### END INIT INFO - -# Author: Foo Bar -# -# Please remove the "Author" lines above and replace them -# with your own name if you copy and modify this script. - -# Do NOT "set -e" - -ZOOBINDIR="<%= scope.lookupvar("zookeeper::service::_zoo_dir") %>/bin" -ZOOCFGDIR=<%= scope.lookupvar("zookeeper::cfg_dir") %> -ZOOCFG="$ZOOCFGDIR/zoo.cfg" -ZOO_LOG_DIR=<%= scope.lookupvar("zookeeper::log_dir") %> - -[ -r "$ZOOCFGDIR/<%= scope.lookupvar("zookeeper::environment_file") %>" ] || exit 0 -. "$ZOOCFGDIR/<%= scope.lookupvar("zookeeper::environment_file") %>" - -[ -e "$ZOOCFGDIR/java.env" ] && . "$ZOOCFGDIR/java.env" - -[ "x$ZOO_LOG4J_PROP" = "x" ] && ZOO_LOG4J_PROP="<%= scope.lookupvar("zookeeper::log4j_prop") %>" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -# -PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC="centralized coordination service" -SCRIPTNAME=/etc/init.d/$NAME - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - -for f in ${ZOOBINDIR}/../zookeeper-*.jar -do - CLASSPATH="$CLASSPATH:$f" -done - -ZOOLIBDIR=${ZOOLIBDIR:-$ZOOBINDIR/../lib} -for i in "$ZOOLIBDIR"/*.jar -do - CLASSPATH="$CLASSPATH:$i" -done - -#add the zoocfg dir to classpath -CLASSPATH=$ZOOCFGDIR:$CLASSPATH - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions - -is_running() -{ - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $JAVA --user $USER --test > /dev/null \ - || return 1 - return 0 -} - -# -# Function that starts the daemon/service -# -do_start() -{ - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - is_running || return 1 - - if [ ! -d $PIDDIR ] - then - mkdir -p $PIDDIR - fi - chown $USER:$GROUP $PIDDIR - - if [ ! -d $ZOO_LOG_DIR ] - then - mkdir -p $ZOO_LOG_DIR - fi - chown $USER:$GROUP $ZOO_LOG_DIR - - start-stop-daemon --start --quiet \ - --pidfile $PIDFILE \ - --make-pidfile \ - --chuid $USER:$GROUP \ - --background \ - --exec $JAVA -- \ - -cp $CLASSPATH \ - $JAVA_OPTS \ - $JVM_FLAGS \ - -Dzookeeper.log.dir=${ZOO_LOG_DIR} \ - -Dzookeeper.root.logger=${ZOO_LOG4J_PROP} \ - $ZOOMAIN $ZOOCFG \ - || return 2 -} - -# -# Function that stops the daemon/service -# -do_stop() -{ - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - is_running && return 1 - - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - [ "$RETVAL" = 0 ] && rm -f $PIDFILE - return "$RETVAL" -} - -case "$1" in - start) - if [ "x$JMXDISABLE" = "x" ] - then - [ "$VERBOSE" != no ] && log_action_msg "$NAME: JMX enabled by default" - # for some reason these two options are necessary on jdk6 on Ubuntu - # accord to the docs they are not necessary, but otw jconsole cannot - # do a local attach - JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY" - else - [ "$VERBOSE" != no ] && log_action_msg "$NAME: JMX disabled by user request" - fi - - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - status) - status_of_proc -p $PIDFILE "$NAME" "$NAME" && exit 0 || exit $? - ;; - restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/templates/zookeeper.RedHat.init.erb b/templates/zookeeper.RedHat.init.erb deleted file mode 100644 index c62f717..0000000 --- a/templates/zookeeper.RedHat.init.erb +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/sh -# -# zookeeper ZooKeeper Server -# -# chkconfig: - 80 05 -# description: Enable ZooKeeper Server -# - -### BEGIN INIT INFO -# Provides: zookeeper -# Default-Start: -# Default-Stop: -# Required-Start: $remote_fs $network -# Required-Stop: $remote_fs $network -# Description: zookeeper Server -# Short-Description: Enable zookeeper Server -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -prog=<%= scope.lookupvar("zookeeper::service_name") %> -desc="Zookeeper Service" - -[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -lockfile="/var/lock/subsys/$prog" -pidfile=<%= scope.lookupvar("zookeeper::pid_path") %> - -[ "x$JMXLOCALONLY" = "x" ] && JMXLOCALONLY=false - -if [ "x$JMXDISABLE" = "x" ] -then - # for some reason these two options are necessary on jdk6 on Ubuntu - # accord to the docs they are not necessary, but otw jconsole cannot - # do a local attach - ZOOMAIN="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY <%= scope.lookupvar("zookeeper::zoo_main") %>" -else - ZOOMAIN=<%= scope.lookupvar("zookeeper::zoo_main") %> -fi - -ZOOBINDIR="<%= scope.lookupvar("zookeeper::service::_zoo_dir") %>/bin" -ZOOCFGDIR=<%= scope.lookupvar("zookeeper::cfg_dir") %> -ZOOCFG="$ZOOCFGDIR/zoo.cfg" -ZOO_LOG_DIR=<%= scope.lookupvar("zookeeper::log_dir") %> - -[ -e "$ZOOCFGDIR/java.env" ] && . "$ZOOCFGDIR/java.env" -[ -e "$ZOOCFGDIR/<%= scope.lookupvar("zookeeper::environment_file") %>" ] && . "$ZOOCFGDIR/<%= scope.lookupvar("zookeeper::environment_file") %>" - -[ "x$ZOO_LOG4J_PROP" = "x" ] && ZOO_LOG4J_PROP="<%= scope.lookupvar("zookeeper::log4j_prop") %>" - -for f in ${ZOOBINDIR}/../zookeeper-*.jar -do - CLASSPATH="$CLASSPATH:$f" -done - -ZOOLIBDIR=${ZOOLIBDIR:-$ZOOBINDIR/../lib} -for i in "$ZOOLIBDIR"/*.jar -do - CLASSPATH="$CLASSPATH:$i" -done - -#add the zoocfg dir to classpath -CLASSPATH=$ZOOCFGDIR:$CLASSPATH - -cmd="java \"-Dzookeeper.log.dir=${ZOO_LOG_DIR}\" \"-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}\" -cp ${CLASSPATH} ${JAVA_OPTS} ${JVMFLAGS} ${ZOOMAIN} ${ZOOCFG} & echo \$! > ${pidfile}" - - -start() { - echo $pidfile - echo -n "Starting $desc $prog: " - touch $pidfile && chown <%= scope.lookupvar("zookeeper::user") %> $pidfile - daemon --user <%= scope.lookupvar("zookeeper::user") %> --pidfile $pidfile "$cmd" - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval -} - -stop() { - echo -n $"Stopping $prog: " - killproc -p $pidfile $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -get_status() { - if [ -f $pidfile ] - then - PID=`cat $pidfile` - if [ -z "`ps -ef | awk '{print $2}' | grep "^$PID$"`" ] - then - echo "$prog stopped but pid file exists" - exit 1 - else - echo "$prog running with pid $PID" - exit 0 - fi - else - echo "$prog stopped" - exit 1 - fi -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - reload) - reload - ;; - condrestart) - [ -e /var/lock/subsys/$prog ] && restart - RETVAL=$? - ;; - status) - get_status - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" - RETVAL=1 -esac - -exit $RETVAL