Skip to content

Commit

Permalink
Merge pull request #142 from hashworks/fix/prometheusExporterConfig
Browse files Browse the repository at this point in the history
Make sure /etc/borg contains the absolutebackupdestdir if it is set
  • Loading branch information
bastelfreak committed Dec 4, 2021
2 parents 2837aa6 + 90c24e0 commit 0907579
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
13 changes: 7 additions & 6 deletions manifests/install.pp
Expand Up @@ -78,6 +78,12 @@
mode => '0755',
}
}

$backupdestdir = $borg::absolutebackupdestdir ? {
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

0 comments on commit 0907579

Please sign in to comment.