summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-13 02:20:24 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-13 02:20:24 +0000
commit58ca9d1241eac3fb982aa673195d5e49ab0a1889 (patch)
tree8515f03f1c1e466ce9d7cee179bc4f4f89e46470 /lib/puppet
parentf9df5236aa75aa2978c7d9ce826aa6b9bf06a711 (diff)
downloadpuppet-58ca9d1241eac3fb982aa673195d5e49ab0a1889.tar.gz
puppet-58ca9d1241eac3fb982aa673195d5e49ab0a1889.tar.xz
puppet-58ca9d1241eac3fb982aa673195d5e49ab0a1889.zip
adding snippet test to verify correct behaviour with missing exec path; also, adding "creates" parameter to exec
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@649 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/type/exec.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index e58c25f24..a86e0207c 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -20,6 +20,14 @@ module Puppet
# we're just using retrieve to verify that the command
# exists and such
def retrieve
+ if file = @parent[:creates]
+ if FileTest.exists?(file)
+ @is = true
+ @should = true
+ return
+ end
+ end
+
cmd = self.parent[:command]
if cmd =~ /^\//
exe = cmd.split(/ /)[0]
@@ -124,6 +132,7 @@ module Puppet
@parameters = [
:path,
:user,
+ :creates,
:cwd,
:refreshonly,
:command
@@ -138,10 +147,14 @@ module Puppet
@paramdoc[:refreshonly] = "The command should only be run as a
refresh mechanism for when a dependent object is changed."
@paramdoc[:command] = "The actual command to execute."
+ @paramdoc[:creates] = "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."
@doc = "Executes external commands. It is critical that all commands
executed using this mechanism can be run multiple times without
- harm, i.e., they are *idempotent*."
+ harm, i.e., they are *idempotent*. One useful way to create idempotent
+ commands is to use the *creates* parameter."
@name = :exec
@namevar = :command
@@ -169,7 +182,6 @@ module Puppet
# if we're not fully qualified, require a path
if self[:command] !~ /^\//
if self[:path].nil?
- puts caller
raise TypeError,
"'%s' is both unqualifed and specified no search path" %
self[:command]
@@ -185,6 +197,15 @@ module Puppet
end
end
+ # FIXME if they try to set this and fail, then we should probably
+ # fail the entire exec, right?
+ def paramcreates=(file)
+ unless file =~ %r{^#{File::SEPARATOR}}
+ raise Puppet::Error, "'creates' files must be fully qualified."
+ end
+ @parameters[:creates] = file
+ end
+
# this might be a very, very bad idea...
def refresh
self.state(:returns).sync