[chef] Can't rescue from a 'package' resource call


Chronological Thread 
  • From: Marcelo de Moraes Serpa < >
  • To:
  • Subject: [chef] Can't rescue from a 'package' resource call
  • Date: Sun, 25 Nov 2012 17:37:24 -0600

Hi list,

I'm trying to ignore the Chef::Exceptions::Package exception from breaking the cook process by wrapping the package method call in a begin;rescue, and rescuing from the Chef::Exceptions::Package exception, but even so, when the package is not present, it just breaks. Am I doing anything wrong? Here's the code:

%w( wget zlib1g-dev libssl-dev libffi-dev libxml2-dev libncurses5-dev libreadline5-dev libreadline-dev ).each do |pkg|
  begin
    package pkg do
      action :install
    end
  rescue Chef::Exceptions::Package => e
    Chef::Log "Could not install #{pkg}"
  end
end

In this specific scenario, the ubuntu VM I'm cooking on doesn't have the libreadline5-dev, and I just want to ignore it and make it try the libreadline-dev instead.

Thanks,

- Marcelo.



Archive powered by MHonArc 2.6.16.

§