Class: Puppet::Provider::Sqlserver

Inherits:
Puppet::Provider
  • Object
show all
Defined in:
lib/puppet/provider/sqlserver.rb

Instance Method Summary collapse

Instance Method Details

#try_execute(command, msg = nil, obfuscate_strings = nil, acceptable_exit_codes = [0]) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/puppet/provider/sqlserver.rb', line 20

def try_execute(command, msg = nil, obfuscate_strings = nil, acceptable_exit_codes = [0])
  res = execute(command.compact, failonfail: false)

  unless acceptable_exit_codes.include?(res.exitstatus)
    msg = "Failure occured when trying to install SQL Server #{@resource[:name]}" if msg.nil?
    msg += " \n Execution of '#{command}' returned #{res.exitstatus}: #{res.strip}"

    obfuscate_strings.each {|str| msg.gsub!(str, '**HIDDEN VALUE**') } unless obfuscate_strings.nil?

    raise Puppet::Error, msg
  end

  res
end