Skip to content

Commit

Permalink
(#9440) exec resource: set path param to path fact
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 7, 2024
1 parent fc698a2 commit 8a1f94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puppet/type/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def sync
newparam(:path) do
desc "The search path used for command execution.
Commands must be fully qualified if no path is specified. Paths
can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list."
can be specified as an array or as a '#{File::PATH_SEPARATOR}' separated list. Defaults to the `path` fact."

defaultto Puppet.runtime[:facter].value('path')

# Support both arrays and colon-separated fields.
def value=(*values)
Expand Down
2 changes: 2 additions & 0 deletions spec/unit/type/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ def instance(path)
let :abs do make_absolute('/bin/echo') end
let :path do make_absolute('/bin') end

allow(Facter).to receive(:value).with('path').and_return('/usr/bin:/bin')

it "should fail with relative command and no path" do
expect { type.new(:command => rel) }.
to raise_error Puppet::Error, /no path was specified/
Expand Down

0 comments on commit 8a1f94c

Please sign in to comment.