forked from soylent/konstantin-fluentd
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from EncoreTechnologies/hotfix/package
Reworking the way that the tdagent gem package provider works and fin…
- Loading branch information
Showing
5 changed files
with
46 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
Puppet::Type.type(:package).provide :tdagent, parent: :gem, source: :gem do | ||
has_feature :install_options, :versionable | ||
|
||
# yes, i know this isn't how you're "supposed" to do it, but because | ||
# we're overriding the "gem" package provider here, we need this to be | ||
# one named provider for use in our package resources. | ||
if Puppet::Util::Platform.windows? | ||
if Puppet::FileSystem.exist?('C:/opt/td-agent/bin/fluent-gem.bat') | ||
# v4 and newer | ||
commands gemcmd: 'C:/opt/td-agent/bin/fluent-gem.bat' | ||
def self.which_from_paths(command, paths) | ||
# copied/inspired by puppet/util.rb which() function | ||
# this allows you to pass in your own custom search paths | ||
paths.each do |dir| | ||
dest = File.expand_path(File.join(dir, command)) | ||
return dest if FileTest.file?(dest) && FileTest.executable?(dest) | ||
end | ||
raise Puppet::Error, _("Provider %{name} package command '%{command}' does not exist on this host, it couldn't be found in the following paths: %{paths}") % { name: name, cmd: cmd, paths: paths } | ||
end | ||
|
||
def self.provider_command | ||
# FUTURE: if this still isn't good enough in the future we could append the PATH | ||
# components and look there too | ||
if Puppet::Util::Platform.windows? | ||
gem_cmd = 'fluent-gem.bat' | ||
search_paths = [ | ||
# v4 and newer | ||
'C:\\opt\\td-agent\\bin', | ||
# v3 and older | ||
'C:\\opt\\td-agent\\embedded\\bin', | ||
] | ||
else | ||
# v3 and older | ||
commands gemcmd: 'C:/opt/td-agent/embedded/bin/fluent-gem.bat' | ||
gem_cmd = 'td-agent-gem' | ||
search_paths = [ | ||
# v3, v4 and newer | ||
'/usr/sbin', | ||
# v0 | ||
'/opt/td-agent/usr/sbin', | ||
] | ||
end | ||
elsif Puppet::FileSystem.exist?('/usr/sbin/td-agent-gem') | ||
# v3, v4 and newer | ||
commands gemcmd: '/usr/sbin/td-agent-gem' | ||
elsif Puppet::FileSystem.exist?('/opt/td-agent/usr/sbin/td-agent-gem') | ||
# v0 | ||
commands gemcmd: '/opt/td-agent/usr/sbin/td-agent-gem' | ||
else | ||
# use PATH to resolve | ||
commands gemcmd: 'td-agent-gem' | ||
which_from_paths(gem_cmd, search_paths) | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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