Reputation: 83
I'm downloading a RPM using wget and I want to check if the package is installed before I download it. I'm not using a RPM repo, so I can't just do
package { ...
ensure => installed
}
How can I do something like:
if HOW_TO_CHECK_IF_PACKAGE_X_IS_INSTALLED
... do wget etc.
Before someone asks, this didn't work for me: Puppet - test if a package already defined?
Upvotes: 0
Views: 4734
Reputation: 83
The solution was a custom facter:
require"puppet"
module Puppet::Parser::Functions
newfunction(:package_installed, :type => :rvalue) do |args|
packageName = args[0]
return system "rpm --quiet -q #{packageName}"
end
end
Upvotes: 0
Reputation: 5190
If you're downloading an RPM and installing it, you could do so like this:
package { 'foo':
ensure => installed,
provider => 'rpm',
source => 'http://example.com/foo.rpm',
}
Upvotes: 3