diff options
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r-- | lib/puppet/provider/naginator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/provider/package/hpux.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/provider/package/openbsd.rb | 4 | ||||
-rw-r--r-- | lib/puppet/provider/selmodule/semodule.rb | 8 | ||||
-rw-r--r-- | lib/puppet/provider/service/daemontools.rb | 8 | ||||
-rw-r--r-- | lib/puppet/provider/service/gentoo.rb | 8 | ||||
-rwxr-xr-x | lib/puppet/provider/service/redhat.rb | 8 | ||||
-rwxr-xr-x | lib/puppet/provider/service/smf.rb | 4 | ||||
-rwxr-xr-x | lib/puppet/provider/service/src.rb | 8 | ||||
-rw-r--r-- | lib/puppet/provider/ssh_authorized_key/parsed.rb | 4 | ||||
-rw-r--r-- | lib/puppet/provider/user/user_role_add.rb | 4 | ||||
-rw-r--r-- | lib/puppet/provider/zone/solaris.rb | 4 |
12 files changed, 17 insertions, 51 deletions
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 592eb43fd..75337f2bf 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -24,11 +24,9 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile end def self.parse(text) - begin Nagios::Parser.new.parse(text.gsub(NAME_STRING, "_naginator_name")) - rescue => detail + rescue => detail raise Puppet::Error, "Could not parse configuration for #{resource_type.name}: #{detail}" - end end def self.to_file(records) diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb index f3283de08..4d5394643 100644 --- a/lib/puppet/provider/package/hpux.rb +++ b/lib/puppet/provider/package/hpux.rb @@ -27,12 +27,10 @@ Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package end def query - begin swlist resource[:name] {:ensure => :present} - rescue + rescue {:ensure => :absent} - end end def uninstall diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb index cff599bca..4a19a883c 100755 --- a/lib/puppet/provider/package/openbsd.rb +++ b/lib/puppet/provider/package/openbsd.rb @@ -76,7 +76,6 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa end def get_version - begin execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process| # our regex for matching pkg_info output regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/ @@ -96,9 +95,8 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa return master_version unless master_version == 0 raise Puppet::Error, "#{version} is not available for this package" end - rescue Puppet::ExecutionFailure + rescue Puppet::ExecutionFailure return nil - end end def query diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb index 0b72618ec..d6bf09a6a 100644 --- a/lib/puppet/provider/selmodule/semodule.rb +++ b/lib/puppet/provider/selmodule/semodule.rb @@ -13,11 +13,9 @@ Puppet::Type.type(:selmodule).provide(:semodule) do end def destroy - begin execoutput("#{command(:semodule)} --remove #{@resource[:name]}") - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not remove policy module: #{detail}"; - end end def exists? @@ -47,11 +45,9 @@ Puppet::Type.type(:selmodule).provide(:semodule) do end def syncversion= (dosync) - begin execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}") - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not upgrade policy module: #{detail}"; - end end # Helper functions diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index f5f2607e3..934e96aea 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -125,16 +125,14 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do end def setupservice - begin if resource[:manifest] Puppet.notice "Configuring #{resource[:name]}" command = [ resource[:manifest], resource[:name] ] #texecute("setupservice", command) rv = system("#{command}") end - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" ) - end end def enabled? @@ -149,7 +147,6 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do end def enable - begin if ! FileTest.directory?(self.daemon) Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}" self.setupservice @@ -160,9 +157,8 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do File.symlink(self.daemon, self.service) end end - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "No daemon directory found for #{self.service}") - end end def disable diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index a3d477751..109524bc0 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -18,11 +18,9 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do end def disable - begin output = update :del, @resource[:name], :default - rescue Puppet::ExecutionFailure + rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not disable #{self.name}: #{output}" - end end def enabled? @@ -45,11 +43,9 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do end def enable - begin output = update :add, @resource[:name], :default - rescue Puppet::ExecutionFailure + rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not enable #{self.name}: #{output}" - end end end diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index b31faa586..3a25db3ac 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -22,11 +22,9 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init # Remove the symlinks def disable - begin output = chkconfig(@resource[:name], :off) - rescue Puppet::ExecutionFailure + rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not disable #{self.name}: #{output}" - end end def enabled? @@ -48,11 +46,9 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init # Don't support them specifying runlevels; always use the runlevels # in the init scripts. def enable - begin output = chkconfig(@resource[:name], :on) - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not enable #{self.name}: #{detail}" - end end def initscript diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index 0407c8479..ca7af9449 100755 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -19,7 +19,6 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do commands :svccfg => "/usr/sbin/svccfg" def setupservice - begin if resource[:manifest] [command(:svcs), "-l", @resource[:name]] if $CHILD_STATUS.exitstatus == 1 @@ -27,9 +26,8 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do svccfg :import, resource[:manifest] end end - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" ) - end end def enable diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index 135edcb65..aed88d531 100755 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -31,7 +31,6 @@ Puppet::Type.type(:service).provide :src, :parent => :base do end def restart - begin execute([command(:lssrc), "-Ss", @resource[:name]]).each do |line| args = line.split(":") @@ -59,13 +58,11 @@ Puppet::Type.type(:service).provide :src, :parent => :base do end end self.fail("No such service found") - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" ) - end end def status - begin execute([command(:lssrc), "-s", @resource[:name]]).each do |line| args = line.split @@ -82,9 +79,8 @@ Puppet::Type.type(:service).provide :src, :parent => :base do return state end self.fail("No such service found") - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" ) - end end end diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index a39f59c54..a9738e761 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -43,11 +43,9 @@ require 'puppet/provider/parsedfile' end def target - begin @resource.should(:target) || File.expand_path("~#{@resource.should(:user)}/.ssh/authorized_keys") - rescue + rescue raise Puppet::Error, "Target not defined and/or specified user does not exist yet" - end end def user diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 880a18b66..7c7c9e315 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -62,11 +62,9 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => end def run(cmd, msg) - begin execute(cmd) - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail raise Puppet::Error, "Could not #{msg} #{@resource.class.name} #{@resource.name}: #{detail}" - end end def transition(type) diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb index 90c9f543c..b2cdd2a2b 100644 --- a/lib/puppet/provider/zone/solaris.rb +++ b/lib/puppet/provider/zone/solaris.rb @@ -238,11 +238,9 @@ Puppet::Type.type(:zone).provide(:solaris) do end def zoneadm(*cmd) - begin adm("-z", @resource[:name], *cmd) - rescue Puppet::ExecutionFailure => detail + rescue Puppet::ExecutionFailure => detail self.fail "Could not #{cmd[0]} zone: #{detail}" - end end def zonecfg(*cmd) |