Skip to content

Commit efb1f25

Browse files
committed
(node/ipa1.cp.lsst.org) enable restic backups of ipa
As this is an offline backup, which takes down freeipa, we only want to enable it on a single node at a time.
1 parent 7c49509 commit efb1f25

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

hieradata/node/ipa1.cp.lsst.org.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
network::interfaces_hash:
33
eth0: # fqdn
44
ipaddress: "139.229.160.6"
5+
profile::core::restic::enable: true # only backup primary ipa node

hieradata/role/ipareplica.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ classes:
33
- "clustershell"
44
- "ipa"
55
- "profile::core::common"
6+
- "profile::core::restic"
67
- "tailscale"
78

89
profile::core::common::disable_ipv6: true
@@ -60,3 +61,14 @@ hosts::entries:
6061
ip: "100.91.143.57"
6162
ipa3.cp.lsst.org:
6263
ip: "100.94.76.56"
64+
65+
restic::repositories:
66+
ipa:
67+
backup_path:
68+
- "/var/lib/ipa/backup"
69+
backup_pre_cmd: "mkdir /var/lib/ipa/backup;/sbin/ipa-backup"
70+
backup_post_cmd: "rm -rf /var/lib/ipa/backup"
71+
backup_timer: "*-*-* 9:23:00"
72+
enable_forget: true
73+
forget_timer: "*-*-* 10:23:00"
74+
forget_flags: "--keep-last 90"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @summary
2+
# Provides an easy way to turn restic backups on or off for a host.
3+
#
4+
# @param enable
5+
# Whether to enable restic backups on this host.
6+
#
7+
class profile::core::restic (
8+
Boolean $enable = false,
9+
) {
10+
if $enable {
11+
include restic
12+
}
13+
}

spec/classes/core/restic_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'profile::core::restic' do
6+
on_supported_os.each do |os, os_facts|
7+
context "on #{os}" do
8+
let(:facts) { os_facts }
9+
10+
context 'with no params' do
11+
it { is_expected.to compile.with_all_deps }
12+
it { is_expected.not_to contain_class('restic') }
13+
end
14+
15+
context 'with enable param' do
16+
let(:params) do
17+
{
18+
enable: true
19+
}
20+
end
21+
22+
it { is_expected.to compile.with_all_deps }
23+
it { is_expected.to contain_class('restic') }
24+
end
25+
end
26+
end
27+
end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'ipa1.cp.lsst.org', :sitepp do
6+
on_supported_os.each do |os, os_facts|
7+
next unless os =~ %r{almalinux-9-x86_64}
8+
9+
context "on #{os}" do
10+
let(:facts) do
11+
lsst_override_facts(os_facts,
12+
is_virtual: true,
13+
virtual: 'kvm',
14+
dmi: {
15+
'product' => {
16+
'name' => 'KVM',
17+
},
18+
})
19+
end
20+
let(:node_params) do
21+
{
22+
role: 'ipareplica',
23+
site: 'cp',
24+
}
25+
end
26+
27+
it { is_expected.to compile.with_all_deps }
28+
29+
include_examples 'vm'
30+
include_examples 'restic common'
31+
32+
it do
33+
is_expected.to contain_restic__repository('ipa').with(
34+
backup_path: %w[
35+
/var/lib/ipa/backup
36+
],
37+
backup_pre_cmd: 'mkdir /var/lib/ipa/backup;/sbin/ipa-backup',
38+
backup_post_cmd: 'rm -rf /var/lib/ipa/backup',
39+
backup_timer: '*-*-* 9:23:00',
40+
enable_forget: true,
41+
forget_timer: '*-*-* 10:23:00',
42+
forget_flags: '--keep-last 90'
43+
)
44+
end
45+
end # on os
46+
end # on_supported_os
47+
end

0 commit comments

Comments
 (0)