Created
May 3, 2013 20:07
-
-
Save coderforhire/5513539 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def install | |
should = @resource.should(:ensure) | |
self.debug "Ensuring => #{should}" | |
wanted = @resource[:name] | |
operation = :install | |
case should | |
when true, false, Symbol | |
# pass | |
should = nil | |
else | |
# Add the package version | |
wanted += "-#{should}" | |
is = self.query | |
if is && Puppet::Util::Package.versioncmp(should, is[:ensure]) < 0 | |
self.debug "Downgrading package #{@resource[:name]} from version #{is[:ensure]} to #{should}" | |
operation = :downgrade | |
end | |
end | |
output = yum "-d", "0", "-e", "0", "-y", operation, wanted | |
is = self.query | |
raise Puppet::Error, "Could not find package #{self.name}" unless is | |
# FIXME: Should we raise an exception even if should == :latest | |
# and yum updated us to a version other than @param_hash[:ensure] ? | |
raise Puppet::Error, "Failed to update to version #{should}, got version #{is[:ensure]} instead" if should && should != is[:ensure] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment