From e1f5fa7ebef0497d33d7cb3618b8ff1666fc696a Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Mon, 24 Apr 2017 19:25:16 +0200 Subject: [PATCH 1/4] add tmpfiles.d config - issue#12 --- manifests/install.pp | 9 +++++++++ spec/acceptance/default_spec.rb | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/manifests/install.pp b/manifests/install.pp index c291606..b0674e3 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -10,5 +10,14 @@ class rsnapshot::install { ensure => $rsnapshot::package_ensure, } + # ensure run directory exists (systemd clears /var/run, so rsnapshot can't create PID files after reboot - issue#12) + $lockpath = pick($rsnapshot::lockpath, $rsnapshot::params::config_lockpath, '/var/run/rsnapshot') + $tmpfiles_d = '/etc/tmpfiles.d' + + file { "${tmpfiles_d}/rsnapshot.conf": + ensure => present, + content => "D ${lockpath} 0755 root root -", + } + } diff --git a/spec/acceptance/default_spec.rb b/spec/acceptance/default_spec.rb index ecd4754..5a49c34 100644 --- a/spec/acceptance/default_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -28,6 +28,10 @@ describe 'rsnapshot' do end end context 'files provisioned' do + describe file('/etc/tmpfiles.d/rsnapshot.conf') do + it { is_expected.to exist } + its(:content) { is_expected.to match 'D /var/run/rsnapshot 0755 root root -' } + end describe file('/etc/rsnapshot/localhost.rsnapshot.conf') do it { is_expected.to exist } its(:content) { is_expected.to match 'backup' } From efa6ef88086e3aecc81662226f98ea11254ee11b Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Mon, 24 Apr 2017 19:42:31 +0200 Subject: [PATCH 2/4] add some tests --- spec/acceptance/default_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/acceptance/default_spec.rb b/spec/acceptance/default_spec.rb index 5a49c34..49e20af 100644 --- a/spec/acceptance/default_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -32,6 +32,9 @@ describe 'rsnapshot' do it { is_expected.to exist } its(:content) { is_expected.to match 'D /var/run/rsnapshot 0755 root root -' } end + describe file('/var/run/rsnapshot') do + it { should be_directory } + end describe file('/etc/rsnapshot/localhost.rsnapshot.conf') do it { is_expected.to exist } its(:content) { is_expected.to match 'backup' } @@ -53,5 +56,9 @@ describe 'rsnapshot' do it { is_expected.to exist } its(:content) { is_expected.to match 'example.com' } end + describe cron do + its(:table) { should match /.*\/etc\/rsnapshot\/localhost.rsnapshot.conf daily.*/ } + its(:table) { should match /.*\/etc\/rsnapshot\/example\.com\.rsnapshot\.conf daily.*/ } + end end end From 3ae826a0e058d124591d9abaee1388bff9146e13 Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Mon, 24 Apr 2017 19:51:57 +0200 Subject: [PATCH 3/4] remove cron test, add file content match --- spec/acceptance/default_spec.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/acceptance/default_spec.rb b/spec/acceptance/default_spec.rb index 49e20af..db8b886 100644 --- a/spec/acceptance/default_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -41,7 +41,7 @@ describe 'rsnapshot' do end describe file('/etc/rsnapshot/example.com.rsnapshot.conf') do it { is_expected.to exist } - its(:content) { is_expected.to match 'backup' } + its(:content) { is_expected.to match 'backup\t/var/\t./' } end describe file('/etc/rsnapshot.conf') do it { is_expected.to exist } @@ -56,9 +56,5 @@ describe 'rsnapshot' do it { is_expected.to exist } its(:content) { is_expected.to match 'example.com' } end - describe cron do - its(:table) { should match /.*\/etc\/rsnapshot\/localhost.rsnapshot.conf daily.*/ } - its(:table) { should match /.*\/etc\/rsnapshot\/example\.com\.rsnapshot\.conf daily.*/ } - end end end From a2dfd903c38343c396efd403c678dac8ab77d691 Mon Sep 17 00:00:00 2001 From: Norbert Varzariu Date: Mon, 24 Apr 2017 19:57:24 +0200 Subject: [PATCH 4/4] fix regex --- spec/acceptance/default_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/default_spec.rb b/spec/acceptance/default_spec.rb index db8b886..304c81a 100644 --- a/spec/acceptance/default_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -41,7 +41,7 @@ describe 'rsnapshot' do end describe file('/etc/rsnapshot/example.com.rsnapshot.conf') do it { is_expected.to exist } - its(:content) { is_expected.to match 'backup\t/var/\t./' } + its(:content) { is_expected.to match 'backup\troot@example.com:/var/\t./' } end describe file('/etc/rsnapshot.conf') do it { is_expected.to exist }