Skip to content

Commit fcb715d

Browse files
committed
Fix error on noop run on initial letsencrypt::certonly setup
1 parent a0bfa89 commit fcb715d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

manifests/certonly.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@
253253
$verify_domains = join(unique($domains), '\' \'')
254254

255255
if $ensure == 'present' {
256-
$exec_ensure = { 'unless' => "/usr/local/sbin/letsencrypt-domain-validation ${live_path} '${verify_domains}'" }
256+
$exec_ensure = { 'unless' => ['test ! -f /usr/local/sbin/letsencrypt-domain-validation',
257+
"/usr/local/sbin/letsencrypt-domain-validation ${live_path} '${verify_domains}'"] }
257258
} else {
258259
$exec_ensure = { 'onlyif' => "/usr/local/sbin/letsencrypt-domain-validation ${live_path} '${verify_domains}'" }
259260
}

spec/defines/letsencrypt_certonly_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
end
4545
it { is_expected.to contain_exec('initialize letsencrypt') }
4646
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com') }
47-
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless "/usr/local/sbin/letsencrypt-domain-validation #{pathprefix}/etc/letsencrypt/live/foo.example.com/cert.pem 'foo.example.com'" }
47+
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless(['test ! -f /usr/local/sbin/letsencrypt-domain-validation', "/usr/local/sbin/letsencrypt-domain-validation #{pathprefix}/etc/letsencrypt/live/foo.example.com/cert.pem 'foo.example.com'"]) }
4848
end
4949

5050
context 'with ensure absent' do
@@ -483,7 +483,7 @@ class { 'letsencrypt::plugin::dns_cloudflare':
483483

484484
it { is_expected.to compile.with_all_deps }
485485
it { is_expected.to contain_file('/foo/bar/baz').with_ensure('directory') }
486-
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless '/usr/local/sbin/letsencrypt-domain-validation /foo/bar/baz/live/foo.example.com/cert.pem \'foo.example.com\'' }
486+
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless(['test ! -f /usr/local/sbin/letsencrypt-domain-validation', '/usr/local/sbin/letsencrypt-domain-validation /foo/bar/baz/live/foo.example.com/cert.pem \'foo.example.com\'']) }
487487
end
488488

489489
context 'on FreeBSD', if: facts[:os]['name'] == 'FreeBSD' do
@@ -495,7 +495,7 @@ class { 'letsencrypt::plugin::dns_cloudflare':
495495
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini email [email protected]') }
496496
it { is_expected.to contain_ini_setting('/usr/local/etc/letsencrypt/cli.ini server https://acme-v02.api.letsencrypt.org/directory') }
497497
it { is_expected.to contain_file('/usr/local/etc/letsencrypt').with_ensure('directory') }
498-
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless '/usr/local/sbin/letsencrypt-domain-validation /usr/local/etc/letsencrypt/live/foo.example.com/cert.pem \'foo.example.com\'' }
498+
it { is_expected.to contain_exec('letsencrypt certonly foo.example.com').with_unless(['test ! -f /usr/local/sbin/letsencrypt-domain-validation', '/usr/local/sbin/letsencrypt-domain-validation /usr/local/etc/letsencrypt/live/foo.example.com/cert.pem \'foo.example.com\'']) }
499499
end
500500
end
501501
end

0 commit comments

Comments
 (0)