From 83091cbc96093ff27b24ceff8f547eef3c1b5d65 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 16 Nov 2021 10:54:45 -0800 Subject: [PATCH] puppet: Swap the one use of the `cron` resource for an /etc/cron.d file. The `cron` resource places its contents in the user's crontab, which makes it unlike every other cron job that Zulip installs. Switch to using `/etc/cron.d` files, like all other cron jobs. --- puppet/zulip/files/cron.d/pg-backup-and-purge | 3 +++ puppet/zulip/manifests/postgresql_backups.pp | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 puppet/zulip/files/cron.d/pg-backup-and-purge diff --git a/puppet/zulip/files/cron.d/pg-backup-and-purge b/puppet/zulip/files/cron.d/pg-backup-and-purge new file mode 100644 index 0000000000..ba186c2c29 --- /dev/null +++ b/puppet/zulip/files/cron.d/pg-backup-and-purge @@ -0,0 +1,3 @@ +PATH=/bin:/usr/bin:/usr/local/bin + +0 2 * * * postgres /usr/local/bin/pg_backup_and_purge diff --git a/puppet/zulip/manifests/postgresql_backups.pp b/puppet/zulip/manifests/postgresql_backups.pp index be87d1f22e..f087692d17 100644 --- a/puppet/zulip/manifests/postgresql_backups.pp +++ b/puppet/zulip/manifests/postgresql_backups.pp @@ -43,15 +43,26 @@ class zulip::postgresql_backups { ], } + # Zulip 4.x and before used the `cron` resource here, which placed + # this in the postgres user's crontab, which was not discoverable. + # Removed 2021-11 in version 5.0; these lines can be removed when we + # drop support for upgrading from Zulip 4 or older. cron { 'pg_backup_and_purge': - ensure => present, + ensure => absent, command => '/usr/local/bin/pg_backup_and_purge', environment => 'PATH=/bin:/usr/bin:/usr/local/bin', hour => 2, minute => 0, target => 'postgres', user => 'postgres', - require => File['/usr/local/bin/pg_backup_and_purge'], + } + file { '/etc/cron.d/pg_backup_and_purge': + ensure => present, + owner => 'root', + group => 'root', + mode => '0644', + source => 'puppet:///modules/zulip/cron.d/pg-backup-and-purge', + require => File['/usr/local/bin/pg_backup_and_purge'], } file { "${zulip::common::nagios_plugins_dir}/zulip_postgresql_backups":