Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure /etc/borg contains the absolutebackupdestdir if it is set #142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions manifests/install.pp
Expand Up @@ -78,6 +78,12 @@
mode => '0755',
}
}

$backupdestdir = $borg::absolutebackupdestdir ? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet, selector statement

Undef => "${borg::username}/${borg::backupdestdir}",
default => $borg::absolutebackupdestdir,
}

# we're now switching to rh-perl524 from centos-sclo-rh (which comes from the foreman module?)
if $borg::create_prometheus_metrics {
if $borg::use_upstream_reporter {
Expand Down Expand Up @@ -110,17 +116,12 @@
file { '/etc/borg':
ensure => 'file',
content => epp("${module_name}/borg.epp", {
'username' => $borg::username,
'backupdestdir' => $borg::backupdestdir,
'backupdestdir' => $backupdestdir,
}),
}
}

# setup a profile to export the backup server/path. Otherwise the CLI tooles don't work
$backupdestdir = $borg::absolutebackupdestdir ? {
Undef => "${borg::username}/${borg::backupdestdir}",
default => $borg::absolutebackupdestdir,
}
file { '/etc/profile.d/borg.sh':
ensure => 'file',
content => epp("${module_name}/borg.sh.epp", {
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/init_spec.rb
Expand Up @@ -183,6 +183,20 @@

it { is_expected.not_to contain_file('/usr/local/bin/borg-backup').with_content(%r{/^\s+borg prune/}) }
end

context 'with absolute backup destination dir present' do
let :params do
{
backupserver: 'localhost',
create_prometheus_metrics: true,
absolutebackupdestdir: '/some/other/path'
}
end

it { is_expected.to contain_file('/etc/borg').with_content(%r{^REPOSITORY=backup:/some/other/path$}) }
it { is_expected.to contain_file('/etc/profile.d/borg.sh').with_content(%r{^export BORG_REPO=backup:/some/other/path$}) }
it { is_expected.to contain_file('/usr/local/bin/borg-backup').with_content(%r{\s*borg_repo="backup:/some/other/path"$}) }
end
end
end
end
5 changes: 2 additions & 3 deletions templates/borg.epp
@@ -1,7 +1,6 @@
<%- | String[1] $username,
String[1] $backupdestdir
<%- | String[1] $backupdestdir
| -%>
# THIS FILE IS MANAGED BY PUPPET
BORG_PASSPHRASE=''
REPOSITORY=backup:<%= $username %>/<%= $backupdestdir %>
REPOSITORY=backup:<%= $backupdestdir %>
COLLECTOR_DIR=/var/lib/prometheus-dropzone