From 220481fab4503d537a2f0cc58340a5ba5200eab9 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Sat, 17 Jun 2017 16:53:49 +0200 Subject: [PATCH] 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 --- files/zuul-executor.init | 2 +- files/zuul-launcher.init | 2 +- files/zuul-merger.init | 2 +- manifests/executor.pp | 3 ++- manifests/init.pp | 7 +++++++ manifests/launcher.pp | 3 ++- manifests/merger.pp | 3 ++- manifests/scheduler.pp | 3 ++- manifests/server.pp | 3 ++- manifests/systemd_reload.pp | 12 ++++++++++++ 10 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 manifests/systemd_reload.pp diff --git a/files/zuul-executor.init b/files/zuul-executor.init index 37816e4..249c85e 100644 --- a/files/zuul-executor.init +++ b/files/zuul-executor.init @@ -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 diff --git a/files/zuul-launcher.init b/files/zuul-launcher.init index 9ea0ce9..16be1dd 100644 --- a/files/zuul-launcher.init +++ b/files/zuul-launcher.init @@ -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 diff --git a/files/zuul-merger.init b/files/zuul-merger.init index e19ffbf..be6740e 100644 --- a/files/zuul-merger.init +++ b/files/zuul-merger.init @@ -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 diff --git a/manifests/executor.pp b/manifests/executor.pp index 271f9a6..392adde 100644 --- a/manifests/executor.pp +++ b/manifests/executor.pp @@ -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 { diff --git a/manifests/init.pp b/manifests/init.pp index 12b9007..8334d80 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 == '' { diff --git a/manifests/launcher.pp b/manifests/launcher.pp index edd313c..ecdda85 100644 --- a/manifests/launcher.pp +++ b/manifests/launcher.pp @@ -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': diff --git a/manifests/merger.pp b/manifests/merger.pp index b77d32d..ec2ea3c 100644 --- a/manifests/merger.pp +++ b/manifests/merger.pp @@ -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': diff --git a/manifests/scheduler.pp b/manifests/scheduler.pp index da6742d..3c00f9f 100644 --- a/manifests/scheduler.pp +++ b/manifests/scheduler.pp @@ -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': diff --git a/manifests/server.pp b/manifests/server.pp index 1792dd5..3c5a320 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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': diff --git a/manifests/systemd_reload.pp b/manifests/systemd_reload.pp new file mode 100644 index 0000000..b758c36 --- /dev/null +++ b/manifests/systemd_reload.pp @@ -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, + } + } +}