diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-08-16 11:45:55 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-08-16 11:45:55 -0700 |
| commit | 66d852bb2c2b66ff5e7c9966fdb510e2edd529db (patch) | |
| tree | c5e682eda7956676f43091927723842c76f6802d /lib | |
| parent | 39116d4a6ed4861e46b16ba26c679a8b346fca00 (diff) | |
| parent | 1049458461b5ec5e1e48ad0244d63eb24626b09d (diff) | |
| download | puppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.tar.gz puppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.tar.xz puppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.zip | |
Merge branch '2.7.x'
Conflicts:
lib/puppet/provider/augeas/augeas.rb
spec/unit/node_spec.rb
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/provider/exec/posix.rb | 32 | ||||
| -rwxr-xr-x | lib/puppet/type/exec.rb | 17 |
2 files changed, 26 insertions, 23 deletions
diff --git a/lib/puppet/provider/exec/posix.rb b/lib/puppet/provider/exec/posix.rb index 157d0f28d..782f1eac6 100644 --- a/lib/puppet/provider/exec/posix.rb +++ b/lib/puppet/provider/exec/posix.rb @@ -76,26 +76,26 @@ Puppet::Type.type(:exec).provide :posix do def checkexe(command) exe = extractexe(command) - if resource[:path] - if Puppet.features.posix? and !File.exists?(exe) - withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do - exe = which(exe) || raise(ArgumentError,"Could not find command '#{exe}'") - end - elsif Puppet.features.microsoft_windows? and !File.exists?(exe) - resource[:path].each do |path| - [".exe", ".ps1", ".bat", ".com", ""].each do |extension| - file = File.join(path, exe+extension) - return if File.exists?(file) - end - end + if File.expand_path(exe) == exe + if !File.exists?(exe) + raise ArgumentError, "Could not find command '#{exe}'" + elsif !File.file?(exe) + raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file" + elsif !File.executable?(exe) + raise ArgumentError, "'#{exe}' is not executable" end + return end - raise ArgumentError, "Could not find command '#{exe}'" unless File.exists?(exe) - unless File.executable?(exe) - raise ArgumentError, - "'#{exe}' is not executable" + if resource[:path] + withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do + return if which(exe) + end end + + # 'which' will only return the command if it's executable, so we can't + # distinguish not found from not executable + raise ArgumentError, "Could not find command '#{exe}'" end def extractexe(command) diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 3ba488f19..35e0c96d7 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -311,17 +311,20 @@ module Puppet end newcheck(:creates, :parent => Puppet::Parameter::Path) do - desc "A file that this command creates. If this + desc <<-EOT + A file that this command creates. If this parameter is provided, then the command will only be run - if the specified file does not exist: + if the specified file does not exist. - exec { \"tar xf /my/tar/file.tar\": - cwd => \"/var/tmp\", - creates => \"/var/tmp/myfile\", - path => [\"/usr/bin\", \"/usr/sbin\"] + exec { "tar -xf /Volumes/nfs02/important.tar": + cwd => "/var/tmp", + creates => "/var/tmp/myfile", + path => ["/usr/bin", "/usr/sbin"] } - " + In this example, if `/var/tmp/myfile` is ever deleted, the exec + will bring it back by re-extracting the tarball. + EOT accept_arrays |
