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/