mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 23:27:19 -04:00
This new command replace the old workflow of `pack`, `unpack` and the `install --local`, and wrap all the logic into one uniform way of installing plugins. The work is based on the flow developed for installing an x-pack inside Logstash, when you call prepare-offline-pack, the specified plugins and their dependencies will be packaged in a zip. And this zip can be installed with the same flow as the pack. Definition: Source Logstash: Where you run the prepare-offline-pack. Target Logstash: Where you install the offline package. PROS: - If you install a .gem in the source logstash, the .gem and his dependencies will be bundled. - The install flow doesn't need to have access to the internet. - Nothing special need to be setup in the target logstash environment. CONS: - The is one minor drawback, the plugins need to have their JARS bundled with them for this flow to work, this is currently the case for all the official plugins. - The source Logstash need to have access to the internet when you install plugins before packaging them. Usage examples: bin/logstash-plugin prepare-offline-pack logstash-input-beats bin/logstash-plugin prepare-offline-pack logstash-filter-jdbc logstash-input-beats bin/logstash-plugin prepare-offline-pack logstash-filter-* bin/logstash-plugin prepare-offline-pack logstash-filter-* logstash-input-beats How to install: bin/logstash-plugin install file:///tmp/logstash-offline-plugins-XXXX.zip Fixes #6404
37 lines
1.4 KiB
Ruby
37 lines
1.4 KiB
Ruby
# encoding: utf-8
|
|
require_relative "pack_command"
|
|
|
|
class LogStash::PluginManager::Unpack < LogStash::PluginManager::PackCommand
|
|
option "--tgz", :flag, "unpack a packaged tar.gz file", :default => !LogStash::Environment.windows?
|
|
option "--zip", :flag, "unpack a packaged zip file", :default => LogStash::Environment.windows?
|
|
|
|
parameter "file", "the package file name", :attribute_name => :package_file, :required => true
|
|
|
|
def execute
|
|
signal_deprecation_warning_for_pack
|
|
|
|
puts("Unpacking #{package_file}")
|
|
|
|
FileUtils.rm_rf(LogStash::Environment::CACHE_PATH)
|
|
validate_cache_location
|
|
archive_manager.extract(package_file, LogStash::Environment::CACHE_PATH)
|
|
puts("Unpacked at #{LogStash::Environment::CACHE_PATH}")
|
|
puts("The unpacked plugins can now be installed in local-only mode using bin/logstash-plugin install --local [plugin name]")
|
|
end
|
|
|
|
private
|
|
|
|
def validate_cache_location
|
|
cache_location = LogStash::Environment::CACHE_PATH
|
|
if File.exist?(cache_location)
|
|
puts("Directory #{cache_location} is going to be overwritten, do you want to continue? (Y/N)")
|
|
override = ( "y" == STDIN.gets.strip.downcase ? true : false)
|
|
if override
|
|
FileUtils.rm_rf(cache_location)
|
|
else
|
|
puts("Unpack cancelled: file #{cache_location} already exists, please delete or move it")
|
|
exit
|
|
end
|
|
end
|
|
end
|
|
end
|