From 529ed33b2c4e18e001206aad2d6f70ccb2e934bb Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sat, 26 Sep 2020 15:42:17 +0200 Subject: [PATCH] Drop Debian 8 support/compatibility --- .sync.yml | 1 - .travis.yml | 8 -- manifests/alertmanager.pp | 8 +- manifests/config.pp | 2 +- manifests/daemon.pp | 9 -- manifests/service_reload.pp | 8 +- metadata.json | 1 - spec/classes/prometheus_spec.rb | 2 +- spec/classes/server_spec.rb | 2 +- spec/defines/daemon_spec.rb | 32 +----- spec/spec_helper_methods.rb | 2 - templates/daemon.debian.erb | 162 ----------------------------- templates/prometheus.debian.erb | 174 -------------------------------- types/initstyle.pp | 1 - 14 files changed, 14 insertions(+), 398 deletions(-) delete mode 100644 templates/daemon.debian.erb delete mode 100644 templates/prometheus.debian.erb diff --git a/.sync.yml b/.sync.yml index 8a4b645db..ddc03c76f 100644 --- a/.sync.yml +++ b/.sync.yml @@ -3,7 +3,6 @@ docker_sets: - set: centos7-64 - set: centos8-64 - - set: debian8-64 - set: debian9-64 - set: debian10-64 - set: ubuntu1604-64 diff --git a/.travis.yml b/.travis.yml index 7b75b3026..07063a472 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,14 +40,6 @@ jobs: bundler_args: --without development release env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=centos8-64 CHECK=beaker services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=debian8-64 CHECK=beaker - services: docker - - rvm: 2.5.3 - bundler_args: --without development release - env: BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_setfile=debian8-64 CHECK=beaker - services: docker - rvm: 2.5.3 bundler_args: --without development release env: BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_setfile=debian9-64 CHECK=beaker diff --git a/manifests/alertmanager.pp b/manifests/alertmanager.pp index c343c2a4b..7c7d587cc 100644 --- a/manifests/alertmanager.pp +++ b/manifests/alertmanager.pp @@ -139,10 +139,10 @@ } $alertmanager_reload = $prometheus::init_style ? { - 'systemd' => "systemctl reload-or-restart ${service_name}", - /^(upstart|none)$/ => "service ${service_name} reload", - /^(sysv|redhat|sles|debian)$/ => "/etc/init.d/${service_name} reload", - 'launchd' => "launchctl stop ${service_name} && launchctl start ${service_name}", + 'systemd' => "systemctl reload-or-restart ${service_name}", + /^(upstart|none)$/ => "service ${service_name} reload", + /^(sysv|redhat|sles)$/ => "/etc/init.d/${service_name} reload", + 'launchd' => "launchctl stop ${service_name} && launchctl start ${service_name}", } exec { 'alertmanager-reload': diff --git a/manifests/config.pp b/manifests/config.pp index daf1825be..e815e531c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -194,7 +194,7 @@ Class['systemd::systemctl::daemon_reload'] -> Class['prometheus::run_service'] } } - 'sysv', 'redhat', 'debian', 'sles': { + 'sysv', 'redhat', 'sles': { $content = $prometheus::server::init_style ? { 'redhat' => template('prometheus/prometheus.sysv.erb'), # redhat and sysv share the same template file default => template("prometheus/prometheus.${prometheus::server::init_style}.erb"), diff --git a/manifests/daemon.pp b/manifests/daemon.pp index bfb881964..e29261914 100644 --- a/manifests/daemon.pp +++ b/manifests/daemon.pp @@ -194,15 +194,6 @@ notify => $notify_service, } } - 'debian': { - file { "/etc/init.d/${name}": - mode => '0555', - owner => 'root', - group => 'root', - content => template('prometheus/daemon.debian.erb'), - notify => $notify_service, - } - } 'sles': { file { "/etc/init.d/${name}": mode => '0555', diff --git a/manifests/service_reload.pp b/manifests/service_reload.pp index 43be6a4b5..5e5f12a2e 100644 --- a/manifests/service_reload.pp +++ b/manifests/service_reload.pp @@ -7,10 +7,10 @@ $init_selector = $prometheus::run_service::init_selector $prometheus_reload = $prometheus::server::init_style ? { - 'systemd' => "systemctl reload-or-restart ${init_selector}", - /^(upstart|none)$/ => "service ${init_selector} reload", - /^(sysv|redhat|sles|debian)$/ => "/etc/init.d/${init_selector} reload", - 'launchd' => "launchctl stop ${init_selector} && launchctl start ${init_selector}", + 'systemd' => "systemctl reload-or-restart ${init_selector}", + /^(upstart|none)$/ => "service ${init_selector} reload", + /^(sysv|redhat|sles)$/ => "/etc/init.d/${init_selector} reload", + 'launchd' => "launchctl stop ${init_selector} && launchctl start ${init_selector}", } exec { 'prometheus-reload': diff --git a/metadata.json b/metadata.json index c7d895c85..5e9e993a6 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,6 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "8", "9", "10" ] diff --git a/spec/classes/prometheus_spec.rb b/spec/classes/prometheus_spec.rb index 28994ab8b..00a4554e4 100644 --- a/spec/classes/prometheus_spec.rb +++ b/spec/classes/prometheus_spec.rb @@ -117,7 +117,7 @@ 'content' => File.read(fixtures('files', "prometheus#{prom_major}.sysv")) ) } - elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'virtuozzolinux-7-x86_64'].include?(os) + elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'virtuozzolinux-7-x86_64'].include?(os) # 'archlinux-5-x86_64' got removed from that list. It has systemd, but we use the repo packages and their shipped unit files. # init_style = 'systemd' diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 825900eb2..1024fec88 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -13,7 +13,7 @@ parameters end - if ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64'].include?(os) + if ['centos-7-x86_64', 'centos-8-x86_64', 'debian-9-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64'].include?(os) prom_version = parameters[:version] || '1.5.2' prom_major = prom_version[0] it { diff --git a/spec/defines/daemon_spec.rb b/spec/defines/daemon_spec.rb index 596fb4cc6..9f6fd62bd 100644 --- a/spec/defines/daemon_spec.rb +++ b/spec/defines/daemon_spec.rb @@ -92,33 +92,7 @@ end # prometheus::config - if ['debian-7-x86_64'].include?(os) - # init_style = 'debian' - - it { - is_expected.to contain_file('/etc/init.d/smurf_exporter').with( - 'mode' => '0555', - 'owner' => 'root', - 'group' => 'root' - ).with_content( - %r{DAEMON_ARGS=''\n} - ).with_content( - %r{USER=smurf_user\n} - ) - } - - context 'with overidden bin_name' do - let(:params) do - parameters.merge(bin_name: 'notsmurf_exporter') - end - - it { - is_expected.to contain_file('/etc/init.d/smurf_exporter').with_content( - %r{DAEMON=/usr/local/bin/notsmurf_exporter} - ) - } - end - elsif ['centos-6-x86_64', 'redhat-6-x86_64'].include?(os) + if ['centos-6-x86_64', 'redhat-6-x86_64'].include?(os) # init_style = 'sysv' it { @@ -142,7 +116,7 @@ ) } end - elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'archlinux-5-x86_64', 'virtuozzolinux-7-x86_64'].include?(os) + elsif ['centos-7-x86_64', 'centos-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'ubuntu-16.04-x86_64', 'ubuntu-18.04-x86_64', 'archlinux-5-x86_64', 'virtuozzolinux-7-x86_64'].include?(os) # init_style = 'systemd' it { is_expected.to contain_class('systemd') } @@ -215,7 +189,7 @@ } end - if ['debian-7-x86_64', 'ubuntu-14.04-x86_64', 'debian-8-x86_64', 'ubuntu-16.04-x86_64'].include?(os) + if os == 'ubuntu-16.04-x86_64' it { is_expected.to contain_file('/etc/default/smurf_exporter').with( 'mode' => '0644', diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb index 5aca2f0fc..7641127fa 100644 --- a/spec/spec_helper_methods.rb +++ b/spec/spec_helper_methods.rb @@ -4,8 +4,6 @@ def os_specific_facts(facts) { service_provider: 'systemd' } when 'Debian' case facts[:os]['release']['major'] - when '8' - { service_provider: 'systemd' } when '9' { service_provider: 'systemd' } when '10' diff --git a/templates/daemon.debian.erb b/templates/daemon.debian.erb deleted file mode 100644 index c9b92f546..000000000 --- a/templates/daemon.debian.erb +++ /dev/null @@ -1,162 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: <%= @name %> -# Required-Start: $local_fs $remote_fs -# Required-Stop: $local_fs $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: S 0 1 6 -# Short-Description: Prometheus <%= @name %> -# Description: Prometheus <%= @name %> -# -### END INIT INFO - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/usr/sbin:/usr/bin:/sbin:/bin:<%= @bin_dir %> -DESC="Prometheus <%= @name %>" -NAME=<%= @name %> -DAEMON=<%= @bin_dir %>/<%= @bin_name %> -PIDFILE=/var/run/$NAME/$NAME.pid -<%- require 'shellwords' -%> -DAEMON_ARGS=<%= Shellwords.split(@options).map{|x| Shellwords.escape(x)}.join('\ ') %> -USER=<%= @user %> -SCRIPTNAME=/etc/init.d/$NAME - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - -# Load the VERBOSE setting and other rcS variables -[ -f /etc/default/rcS ] && . /etc/default/rcS - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions - -# -# Function to create run directory -# -mkrundir() { - [ ! -d /var/run/<%= @name %> ] && mkdir -p /var/run/<%= @name %> - chown $USER /var/run/<%= @name %> -} - -# -# 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 - mkrundir - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background --make-pidfile --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background --make-pidfile -- \ - $DAEMON_ARGS \ - || 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 - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# -# Function that sends a SIGHUP to the daemon/service -# -do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 -} - -case "$1" in - start) - [ "$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 - ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; - 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 - ;; - status) - status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? - ;; - *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/templates/prometheus.debian.erb b/templates/prometheus.debian.erb deleted file mode 100644 index 8c08ba528..000000000 --- a/templates/prometheus.debian.erb +++ /dev/null @@ -1,174 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: prometheus -# Required-Start: $local_fs $remote_fs -# Required-Stop: $local_fs $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: S 0 1 6 -# Short-Description: Prometheus monitoring system -# Description: The Prometheus monitoring system and time series database. https://prometheus.io/ -# -### END INIT INFO - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/usr/sbin:/usr/bin:/sbin:/bin:<%= scope.lookupvar('prometheus::server::bin_dir') %> -DESC="Prometheus monitoring framework" -NAME=prometheus -DAEMON=<%= scope.lookupvar('prometheus::server::bin_dir') %>/$NAME -PIDFILE=/var/run/$NAME/$NAME.pid -DAEMON_ARGS="<%= @daemon_flags.join("\n ") %> - <%= scope.lookupvar('prometheus::server::extra_options') %>" -USER=<%= scope.lookupvar('prometheus::server::user') %> -SCRIPTNAME=/etc/init.d/$NAME - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - -# Load the VERBOSE setting and other rcS variables -[ -f /etc/default/rcS ] && . /etc/default/rcS - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions - -# -# Function to create run directory -# -mkrundir() { - [ ! -d /var/run/prometheus ] && mkdir -p /var/run/prometheus - chown $USER /var/run/prometheus -} - -# -# 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 - mkrundir - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background --make-pidfile --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background --make-pidfile -- \ - $DAEMON_ARGS \ - || return 2 - - for i in `seq 1 30`; do - if ! start-stop-daemon --quiet --stop --test --pidfile $PIDFILE --exec $DAEMON --user $USER; then - RETVAL=2 - sleep 1 - continue - fi - if "$DAEMON" info ${RPC_ADDR} >/dev/null; then - return 0 - fi - done - return "$RETVAL" -} - - -# -# 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 - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -# -# Function that sends a SIGHUP to the daemon/service -# -do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 -} - -case "$1" in - start) - [ "$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 - ;; - #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; - restart|reload|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 - ;; - status) - status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? - ;; - *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - -: diff --git a/types/initstyle.pp b/types/initstyle.pp index 3d024a5a7..f9e709376 100644 --- a/types/initstyle.pp +++ b/types/initstyle.pp @@ -3,7 +3,6 @@ 'redhat', 'systemd', 'sles', - 'debian', 'launchd', 'upstart', 'none',