diff options
author | Nigel Kersten <nigelk@google.com> | 2009-08-04 16:38:06 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-08-08 09:37:31 +1000 |
commit | 79d705faec6b7de2bd644e77e5e4c88e8974f207 (patch) | |
tree | 3c329afd0ede889777eb6553ee445971771d25c0 /lib/puppet | |
parent | b611c34de2ff9fe35633ca2154bc64c6c793af7d (diff) | |
download | puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.tar.gz puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.tar.xz puppet-79d705faec6b7de2bd644e77e5e4c88e8974f207.zip |
Fixes #2499. Allows execs to specify an array for the returns parameter
Diffstat (limited to 'lib/puppet')
-rwxr-xr-x | lib/puppet/type/exec.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index 730417cda..a68bfb189 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -70,7 +70,7 @@ module Puppet @checks.keys end - newproperty(:returns) do |property| + newproperty(:returns, :array_matching => :all) do |property| include Puppet::Util::Execution munge do |value| value.to_s @@ -79,8 +79,9 @@ module Puppet defaultto "0" attr_reader :output - desc "The expected return code. An error will be returned if the - executed command returns something else. Defaults to 0." + desc "The expected return code(s). An error will be returned if the + executed command returns something else. Defaults to 0. Can be + specified as an array of acceptable return codes or a single value." # Make output a bit prettier def change_to_s(currentvalue, newvalue) @@ -131,9 +132,9 @@ module Puppet end end - if status.exitstatus.to_s != self.should.to_s - self.fail("%s returned %s instead of %s" % - [self.resource[:command], status.exitstatus, self.should.to_s]) + unless self.should.include?(status.exitstatus.to_s) + self.fail("%s returned %s instead of one of [%s]" % + [self.resource[:command], status.exitstatus, self.should.join(",")]) end return event |