Skip to content

Commit 22e0b3d

Browse files
committed
Run env-sourcing issue/renew execs via the shell provider
The command now starts with the shell builtin 'set -a', which the default posix exec provider rejects ('Could not find command set') because it requires an executable first word. Use provider => shell when the env.sh prefix is present; the commands already rely on shell semantics (>/dev/null, $(...)). Spec now declares an acme::request to cover the issue/renew execs on the acme host.
1 parent aa83259 commit 22e0b3d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

manifests/request.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,13 @@
165165
$env_file = "${cfg_dir}/profile_${use_profile}/env.sh"
166166
$env_prefix = "set -a && . \'${env_file}\' && set +a &&"
167167
$env_require = [File[$env_file]]
168+
# The command now starts with a shell builtin; the default provider
169+
# insists on an executable first word, so run it via /bin/sh.
170+
$env_provider = 'shell'
168171
} else {
169172
$env_prefix = ''
170173
$env_require = []
174+
$env_provider = undef
171175
}
172176

173177
if defined('$_hook_params_pre') and ($_hook_params_pre =~ Hash) {
@@ -356,6 +360,7 @@
356360
unless => $le_check_command,
357361
path => $path,
358362
environment => $hook_params,
363+
provider => $env_provider,
359364
command => $le_command_signcsr,
360365
timeout => $acme::exec_timeout,
361366
# Run this exec only if no old cert can be found.
@@ -383,6 +388,7 @@
383388
unless => $le_check_command,
384389
path => $path,
385390
environment => $hook_params,
391+
provider => $env_provider,
386392
command => $le_command_renew,
387393
timeout => $acme::exec_timeout,
388394
returns => [0,2],

spec/classes/acme_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@
165165
profiles: sensitive(profiles),
166166
}
167167
end
168+
# acme::request is normally collected as an exported resource; declare one directly.
169+
let(:post_condition) do
170+
<<-MANIFEST
171+
acme::request { 'test.example.com':
172+
csr => 'dummy-csr',
173+
altnames => [],
174+
use_account => '#{le_account}',
175+
use_profile => 'pdns',
176+
ca => '#{le_ca}',
177+
}
178+
MANIFEST
179+
end
168180

169181
it { is_expected.to compile.with_all_deps }
170182
it { is_expected.to contain_class('acme::request::handler') }
@@ -176,6 +188,10 @@
176188
it { is_expected.to contain_file('/etc/acme.sh/configs/profile_pdns').with_ensure('directory').with_mode('0700') }
177189
it { is_expected.to contain_file('/etc/acme.sh/configs/profile_pdns/env.sh').with_mode('0600').with_show_diff(false).with_content(sensitive(%r{^export PDNS_Url='https://pdns.example.com'$})) }
178190
it { is_expected.to contain_file('/etc/acme.sh/configs/profile_pdns/env.sh').with_content(sensitive(%r{^export PDNS_Token='tok'\\''en'$})) }
191+
192+
# 'set -a' is a shell builtin: the exec must run through the shell provider
193+
it { is_expected.to contain_exec('issue-certificate-test.example.com').with_provider('shell').with_command(%r{^set -a && \. '/etc/acme.sh/configs/profile_pdns/env\.sh' && set \+a && }) }
194+
it { is_expected.to contain_exec('renew-certificate-test.example.com').with_provider('shell') }
179195
end
180196

181197
context 'on Puppet Server with custom ca_whitelist' do

0 commit comments

Comments
 (0)