2020-10-31 07:51:38 +00:00
|
|
|
vector_url = ''
|
|
|
|
vector_deb = ''
|
|
|
|
|
|
|
|
tag = ''
|
|
|
|
vtag = ''
|
|
|
|
|
|
|
|
# Calculate the Download URL:
|
|
|
|
begin
|
|
|
|
require 'net/http'
|
|
|
|
|
2021-09-23 10:15:06 +00:00
|
|
|
|
|
|
|
uri = URI.parse('https://github.com/vectordotdev/vector/releases/latest')
|
2020-10-31 07:51:38 +00:00
|
|
|
|
|
|
|
Timeout.timeout(3) do
|
|
|
|
response = Net::HTTP.get_response(uri)
|
|
|
|
|
|
|
|
vtag = $1 if response.body =~ %r{tag\/(v\d+\.\d+\.\d+)}
|
|
|
|
tag = vtag.sub(/^v/, '')
|
|
|
|
|
2020-12-06 03:03:42 +00:00
|
|
|
vector_deb = "#{node['vector']['debPrefix']}#{tag}#{node['vector']['debPostfix']}"
|
2020-10-31 07:51:38 +00:00
|
|
|
vector_url = "#{node['vector']['url']}/#{vtag}/#{vector_deb}"
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# Abort the chef client process:
|
|
|
|
raise 'Cannot connect to http://github.com.'
|
|
|
|
end
|
|
|
|
|
|
|
|
# バージョン確認して、アップデート必要かどうか確認
|
|
|
|
result = run_command("vector --version 2>&1 | grep #{tag}", error: false)
|
|
|
|
if result.exit_status != 0
|
|
|
|
# Download:
|
|
|
|
TMP = "/tmp/#{vector_deb}"
|
|
|
|
|
|
|
|
execute "wget #{vector_url} -O #{TMP}"
|
|
|
|
|
|
|
|
execute "dpkg -i #{TMP}"
|
|
|
|
end
|