mirror of https://github.com/zulip/zulip.git
puppet: Purge all un-managed supervisor configuration files.
Relying on `defined(Class['...'])` makes the class sensitive to resource evaluation ordering, and thus brittle. It is also only functional for a single service (thumbor). Generalize by using `purge => true` for the directory to automatically remove all un-managed files. This is more general than the previous form, and may result in additional not-managed services being removed.
This commit is contained in:
parent
4cca1a2076
commit
3ab9b31d2f
|
@ -27,4 +27,4 @@ serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket
|
|||
; include files themselves.
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
files = /etc/supervisor/conf.d/*.conf /etc/supervisor/conf.d/zulip/*.conf
|
||||
|
|
|
@ -5,7 +5,7 @@ class zulip::common {
|
|||
$nagios_plugins = 'monitoring-plugins-basic'
|
||||
$nagios_plugins_dir = '/usr/lib/nagios/plugins'
|
||||
$nginx = 'nginx-full'
|
||||
$supervisor_conf_dir = '/etc/supervisor/conf.d'
|
||||
$supervisor_system_conf_dir = '/etc/supervisor/conf.d'
|
||||
$supervisor_conf_file = '/etc/supervisor/supervisord.conf'
|
||||
$supervisor_service = 'supervisor'
|
||||
$supervisor_start = '/etc/init.d/supervisor start'
|
||||
|
@ -15,7 +15,7 @@ class zulip::common {
|
|||
$nagios_plugins = 'nagios-plugins'
|
||||
$nagios_plugins_dir = '/usr/lib64/nagios/plugins'
|
||||
$nginx = 'nginx'
|
||||
$supervisor_conf_dir = '/etc/supervisord.d/conf.d'
|
||||
$supervisor_system_conf_dir = '/etc/supervisord.d/conf.d'
|
||||
$supervisor_conf_file = '/etc/supervisord.conf'
|
||||
$supervisor_service = 'supervisord'
|
||||
$supervisor_start = 'systemctl start supervisord'
|
||||
|
@ -25,4 +25,5 @@ class zulip::common {
|
|||
fail('osfamily not supported')
|
||||
}
|
||||
}
|
||||
$supervisor_conf_dir = "${supervisor_system_conf_dir}/zulip"
|
||||
}
|
||||
|
|
|
@ -1,15 +1,37 @@
|
|||
class zulip::supervisor {
|
||||
$supervisor_service = $zulip::common::supervisor_service
|
||||
|
||||
package { 'supervisor': ensure => 'installed' }
|
||||
|
||||
if $::osfamily == 'redhat' {
|
||||
file { $zulip::common::supervisor_conf_dir:
|
||||
ensure => 'directory',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
file { $zulip::common::supervisor_system_conf_dir:
|
||||
ensure => 'directory',
|
||||
require => Package['supervisor'],
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
|
||||
$supervisor_service = $zulip::common::supervisor_service
|
||||
file { $zulip::common::supervisor_conf_dir:
|
||||
ensure => 'directory',
|
||||
require => Package['supervisor'],
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
purge => true,
|
||||
recurse => true,
|
||||
notify => Service[$supervisor_service],
|
||||
}
|
||||
|
||||
# These files were moved from /etc/supervisor/conf.d/ into a zulip/
|
||||
# subdirectory in 2020-10 in version 4.0; these lines can be removed
|
||||
# in Zulip version 5.0 and later.
|
||||
file { [
|
||||
"${zulip::common::supervisor_system_conf_dir}/cron.conf",
|
||||
"${zulip::common::supervisor_system_conf_dir}/nginx.conf",
|
||||
"${zulip::common::supervisor_system_conf_dir}/thumbor.conf",
|
||||
"${zulip::common::supervisor_system_conf_dir}/zulip_db.conf",
|
||||
"${zulip::common::supervisor_system_conf_dir}/zulip.conf",
|
||||
]:
|
||||
ensure => absent,
|
||||
}
|
||||
|
||||
# In the dockervoyager environment, we don't want/need supervisor to be started/stopped
|
||||
# /bin/true is used as a decoy command, to maintain compatibility with other
|
||||
|
@ -81,18 +103,4 @@ class zulip::supervisor {
|
|||
source => 'puppet:///modules/zulip/supervisor/supervisord.conf',
|
||||
notify => Exec['supervisor-restart'],
|
||||
}
|
||||
|
||||
# We need a block here to handle deleting the old thumbor.conf file,
|
||||
# unless zulip::thumbor has been enabled. It would be cleaner
|
||||
# to use tidy instead of exec here, but notify is broken with it
|
||||
# (https://tickets.puppetlabs.com/browse/PUP-6021)
|
||||
# so we wouldn't be able to notify the supervisor service.
|
||||
$thumbor_enabled = defined(Class['zulip::thumbor'])
|
||||
if !$thumbor_enabled {
|
||||
exec { 'cleanup_thumbor_supervisor_conf_file':
|
||||
command => "rm ${zulip::common::supervisor_conf_dir}/thumbor.conf",
|
||||
onlyif => "test -e ${zulip::common::supervisor_conf_dir}/thumbor.conf",
|
||||
notify => Service[$zulip::common::supervisor_service],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue