diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-07 17:48:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-07 17:48:51 +0000 |
| commit | 99c8a548c7980408cde0ffc51a3b7685a4965978 (patch) | |
| tree | d48b0bb7e179c90e53909466fc31395fef09e272 /lib | |
| parent | dd71a514b6970d3b4f8167a4f29849b1b1fc631d (diff) | |
| download | puppet-99c8a548c7980408cde0ffc51a3b7685a4965978.tar.gz puppet-99c8a548c7980408cde0ffc51a3b7685a4965978.tar.xz puppet-99c8a548c7980408cde0ffc51a3b7685a4965978.zip | |
Adding a parameter to allow you to override how an exec refreshes itself.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2173 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/puppet/type/exec.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 4a5bbd08f..9dfa2b05e 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -37,15 +37,18 @@ module Puppet obviously different images, so ``exec`` had to be treated specially. It is recommended to avoid duplicate names whenever possible. + + Note that if an ``exec`` receives an event from another resource, + it will get executed again (or execute the command specified in + ``refresh``, if there is one). There is a strong tendency to use ``exec`` to do whatever work Puppet can't already do; while this is obviously acceptable (and unavoidable) in the short term, it is highly recommended to migrate work from ``exec`` - to real Puppet element types as quickly as possible. If you find that + to native Puppet types as quickly as possible. If you find that you are doing a lot of work with ``exec``, please at least notify us at Reductive Labs what you are doing, and hopefully we can work with - you to get a native element type for the work you are doing. In general, - it is a Puppet bug if you need ``exec`` to do your work." + you to get a native element type for the work you are doing." require 'open3' require 'puppet/type/property' @@ -236,6 +239,17 @@ module Puppet newvalues(*values) end + newparam(:refresh) do + desc "How to refresh this command. By default, the exec is just + called again when it receives an event from another resource, + but this parameter allows you to define a different command + for refreshing." + + validate do |command| + @parent.validatecmd(command) + end + end + newparam(:env) do desc "Any additional environment variables you want to set for a command. Note that if you use this to set PATH, it will override @@ -487,7 +501,11 @@ module Puppet # this might be a very, very bad idea... def refresh if self.check - self.property(:returns).sync + if cmd = self[:refresh] + self.run(cmd) + else + self.property(:returns).sync + end end end |
