Make services work with systemd

Without this patch, the SysV init scripts defined in this module will
not be recognized by systemd and puppet will fail to enable the
services. This is because between installing the init script and
starting the service, systemd needs to be reloaded. This patch adds a
new class to define the systemd reload. The conditional logic for
whether the reload exec should be in the catalog is defined in the
class. Then the file and service resources that depend on the reload
define their relationships to the new class rather than to the exec
resource so that the conditional logic does not have to be repeated for
every resource.

We also need to correct a bug in the init scripts themselves. The
Provides statement needs to give a unique service name, not just 'zuul'.
If it is not unique, insserv will error with "service zuul already
provided!" when systemd tries to enable the service.

Change-Id: Ica849094c6011806bdd0b205ba6b2b73856b7aa6
This commit is contained in:
Colleen Murphy 2017-06-17 16:53:49 +02:00
parent 7028052386
commit 220481fab4
10 changed files with 32 additions and 8 deletions

View File

@ -1,6 +1,6 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: zuul
# Provides: zuul-executor
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5

View File

@ -1,6 +1,6 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: zuul
# Provides: zuul-launcher
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5

View File

@ -1,6 +1,6 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: zuul
# Provides: zuul-merger
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5

View File

@ -36,7 +36,8 @@ class zuul::executor (
name => 'zuul-executor',
enable => true,
hasrestart => true,
require => File['/etc/init.d/zuul-executor'],
require => [File['/etc/init.d/zuul-executor'],
Class['zuul::systemd_reload']]
}
if $manage_log_conf {

View File

@ -78,6 +78,8 @@ class zuul (
include ::httpd
include ::pip
include ::zuul::systemd_reload
if ($python_version == 3) {
include ::pip::python3
$pip_provider = pip3
@ -449,6 +451,7 @@ class zuul (
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul.init',
notify => Class['zuul::systemd_reload'],
}
file { '/etc/init.d/zuul-scheduler':
@ -457,6 +460,7 @@ class zuul (
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul-scheduler.init',
notify => Class['zuul::systemd_reload'],
}
file { '/etc/init.d/zuul-merger':
@ -465,6 +469,7 @@ class zuul (
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul-merger.init',
notify => Class['zuul::systemd_reload'],
}
file { '/etc/init.d/zuul-launcher':
@ -473,6 +478,7 @@ class zuul (
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul-launcher.init',
notify => Class['zuul::systemd_reload'],
}
file { '/etc/init.d/zuul-executor':
@ -481,6 +487,7 @@ class zuul (
group => 'root',
mode => '0555',
source => 'puppet:///modules/zuul/zuul-executor.init',
notify => Class['zuul::systemd_reload'],
}
if $proxy_ssl_cert_file_contents == '' {

View File

@ -25,7 +25,8 @@ class zuul::launcher (
name => 'zuul-launcher',
enable => true,
hasrestart => true,
require => File['/etc/init.d/zuul-launcher'],
require => [File['/etc/init.d/zuul-launcher'],
Class['zuul::systemd_reload']]
}
exec { 'zuul-launcher-reload':

View File

@ -24,7 +24,8 @@ class zuul::merger (
name => 'zuul-merger',
enable => true,
hasrestart => true,
require => File['/etc/init.d/zuul-merger'],
require => [File['/etc/init.d/zuul-merger'],
Class['zuul::systemd_reload']]
}
cron { 'zuul_repack':

View File

@ -24,7 +24,8 @@ class zuul::scheduler (
ensure => $ensure,
enable => true,
hasrestart => true,
require => File['/etc/init.d/zuul-scheduler'],
require => [File['/etc/init.d/zuul-scheduler'],
Class['zuul::systemd_reload']]
}
exec { 'zuul-reload':

View File

@ -25,7 +25,8 @@ class zuul::server (
name => 'zuul',
enable => true,
hasrestart => true,
require => File['/etc/init.d/zuul'],
require => [File['/etc/init.d/zuul'],
Class['zuul::systemd_reload']]
}
exec { 'zuul-reload':

View File

@ -0,0 +1,12 @@
# zuul::systemd_reload
#
class zuul::systemd_reload(
) {
if versioncmp($::operatingsystemmajversion, '16.04') >= 0 and ! defined(Exec['systemctl-daemon-reload']) {
exec {'systemctl-daemon-reload':
command => 'systemctl daemon-reload',
path => '/bin:/usr/bin',
refreshonly => true,
}
}
}