Skip to content

Commit c6da2dc

Browse files
committed
tarsnap: disable backups on future stage wordpress hosts
We're not interested in backing up staging data that can be re-created anyways.
1 parent f9953ce commit c6da2dc

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

hieradata/environments/staging/roles/docs/wordpress.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ profile::wordpress::docs::builder_email: [email protected]
33
profile::wordpress::docs::robots_txt_deny_all: true
44
profile::wordpress::docs::wordpress_version: ~
55

6+
profile::tarsnap::enabled: false
7+
68
profile::certbot::certificates:
79
wordpress:
810
domains:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Was previously enabled on this host, which is now being removed.
2+
profile::tarsnap::enabled: true

modules/profile/manifests/tarsnap.pp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# @summary configures the tarsnap backup client
2-
class profile::tarsnap () {
3-
class { 'tarsnap': }
2+
class profile::tarsnap (
3+
Boolean $enable = lookup('profile::tarsnap::enabled', {default_value => true}),
4+
) {
5+
if $enable {
6+
class { 'tarsnap': }
7+
}
48
}

modules/tarsnap/manifests/backup.pp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
Optional[String[1]] $take_backup_command = undef,
55
Jqlib::Ensure $ensure = present,
66
) {
7-
# todo: move to a separate class?
8-
if !defined(File['/etc/tarsnap.conf']) {
9-
file { '/etc/tarsnap.conf':
10-
ensure => file,
11-
source => 'puppet:///modules/tarsnap/backup/tarsnap.conf',
12-
}
13-
14-
file { '/etc/tarsnap.key':
15-
ensure => file,
16-
content => jqlib::secret("tarsnap-keys/${::fqdn}.key"),
17-
owner => 'root',
18-
group => 'root',
19-
mode => '0440',
20-
show_diff => false,
21-
}
22-
23-
file { '/usr/local/sbin/jq-tarsnap-take-backup':
24-
ensure => file,
25-
source => 'puppet:///modules/tarsnap/backup/jq-tarsnap-take-backup.sh',
26-
owner => 'root',
27-
group => 'root',
28-
mode => '0554',
29-
}
30-
}
31-
327
$hour = fqdn_rand(24, "backup-hour-${title}")
338
$minute = fqdn_rand(60, "backup-minute-${title}")
349

@@ -37,11 +12,12 @@
3712
"/usr/local/sbin/jq-tarsnap-take-backup ${title} ${paths.join(' ')}"
3813
].filter |$it| { $it != undef }
3914

40-
systemd::timer { "backup-${title}":
15+
@systemd::timer { "backup-${title}":
4116
description => "Back up ${title} to Tarsnap",
4217
user => 'root',
4318
command => $commands,
4419
interval => ["OnCalendar=*-*-* ${hour}:${minute}:00"],
4520
require => Package['tarsnap'],
21+
tag => 'tarsnap::backup',
4622
}
4723
}

modules/tarsnap/manifests/init.pp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,28 @@
3333
mode => '0755',
3434
require => [Systemd::Sysuser['tarsnap'], Service['systemd-sysusers']],
3535
}
36+
37+
file { '/etc/tarsnap.conf':
38+
ensure => file,
39+
source => 'puppet:///modules/tarsnap/backup/tarsnap.conf',
40+
}
41+
42+
file { '/etc/tarsnap.key':
43+
ensure => file,
44+
content => jqlib::secret("tarsnap-keys/${::fqdn}.key"),
45+
owner => 'root',
46+
group => 'root',
47+
mode => '0440',
48+
show_diff => false,
49+
}
50+
51+
file { '/usr/local/sbin/jq-tarsnap-take-backup':
52+
ensure => file,
53+
source => 'puppet:///modules/tarsnap/backup/jq-tarsnap-take-backup.sh',
54+
owner => 'root',
55+
group => 'root',
56+
mode => '0554',
57+
}
58+
59+
Systemd::Timer <| tag == 'tarsnap::backup' |>
3660
}

0 commit comments

Comments
 (0)