1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2024-11-09 20:50:34 +00:00
puppet-fluentd/lib/puppet/provider/package/fluentd-gem.rb
Kris Lamoureux 6620a30633
Upgrade to td-agent v4 on older Puppet installs
The fluentd_gem provider for installing fluentd plugins uses
Puppet's built-in gem provider. Unfortunately, that gem provider
on our Puppet version is not compatible with td-agent's new embedded
Ruby since it includes the no-rdoc and no-ri flags deprecated and
replaced by the no-document flag. This install function override
replaces the flags and might be removable after a Puppet upgrade.
2022-05-18 15:24:34 -04:00

36 lines
1.2 KiB
Ruby

require 'puppet/provider/package'
require 'uri'
# Ruby gems support.
Puppet::Type.type(:package).provide :fluentd_gem, :parent => :gem do
desc "Fluentd (td-agent) Embedded Ruby Gem support. If a URL is passed via `source`, then
that URL is used as the remote gem repository; if a source is present but is
not a valid URL, it will be interpreted as the path to a local gem file. If
source is not present at all, the gem will be installed from the default gem
repositories."
confine :exists => "/opt/td-agent/bin/gem"
has_feature :versionable, :install_options
commands :gemcmd => "/opt/td-agent/bin/gem"
def install(useversion = true)
command = [command(:gemcmd), "install"]
command << "--no-document" << resource[:name]
output = execute(command)
# Apparently some stupid gem versions don't exit non-0 on failure
self.fail "Could not install: #{output.chomp}" if output.include?("ERROR")
end
def uninstall
command = [command(:gemcmd), "uninstall"]
command << "-x" << "-a" << resource[:name]
output = execute(command)
# Apparently some stupid gem versions don't exit non-0 on failure
self.fail "Could not uninstall: #{output.chomp}" if output.include?("ERROR")
end
end