From 8a1f94c9a2dd876ef8cbcf275d77a20e408934f1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 7 Aug 2024 16:21:38 +0200 Subject: [PATCH] (#9440) exec resource: set path param to path fact --- lib/puppet/type/exec.rb | 4 +++- spec/unit/type/exec_spec.rb | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index fb47b133848..1cd8779362a 100644 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -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) diff --git a/spec/unit/type/exec_spec.rb b/spec/unit/type/exec_spec.rb index ebc6f48038a..48e33000b7f 100644 --- a/spec/unit/type/exec_spec.rb +++ b/spec/unit/type/exec_spec.rb @@ -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/