Merge pull request 'Vectorのインストールをapt経由で行う' (#90) from vector-installation-url-change-again into master
Reviewed-on: #90
This commit is contained in:
commit
c9b324849b
|
@ -1,37 +1,22 @@
|
||||||
vector_url = ''
|
KEY='https://repositories.timber.io/public/vector/gpg.3543DB2D0A2BC4B8.key'
|
||||||
vector_deb = ''
|
|
||||||
|
|
||||||
tag = ''
|
execute "wget -O /tmp/vector.key #{KEY}" do
|
||||||
vtag = ''
|
not_if 'apt-key list | grep "1E46 C153"'
|
||||||
|
|
||||||
# Calculate the Download URL:
|
|
||||||
begin
|
|
||||||
require 'net/http'
|
|
||||||
|
|
||||||
|
|
||||||
uri = URI.parse('https://github.com/vectordotdev/vector/releases/latest')
|
|
||||||
|
|
||||||
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/, '')
|
|
||||||
|
|
||||||
vector_deb = "#{node['vector']['debPrefix']}#{tag}#{node['vector']['debPostfix']}"
|
|
||||||
vector_url = "#{node['vector']['url']}/#{vtag}/#{vector_deb}"
|
|
||||||
end
|
|
||||||
rescue
|
|
||||||
# Abort the chef client process:
|
|
||||||
raise 'Cannot connect to http://github.com.'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# バージョン確認して、アップデート必要かどうか確認
|
execute 'apt-key add /tmp/vector.key' do
|
||||||
result = run_command("vector --version 2>&1 | grep #{tag}", error: false)
|
not_if 'apt-key list | grep "1E46 C153"'
|
||||||
if result.exit_status != 0
|
|
||||||
# Download:
|
|
||||||
TMP = "/tmp/#{vector_deb}"
|
|
||||||
|
|
||||||
execute "wget #{vector_url} -O #{TMP}"
|
|
||||||
|
|
||||||
execute "dpkg -i #{TMP}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Retrieve the Ubuntu code:
|
||||||
|
DIST = run_command('lsb_release -cs').stdout.chomp
|
||||||
|
|
||||||
|
# Deploy the `apt` sources:
|
||||||
|
template '/etc/apt/sources.list.d/timber-vector.list' do
|
||||||
|
action :create
|
||||||
|
variables(distribution: DIST)
|
||||||
|
end
|
||||||
|
|
||||||
|
execute 'apt update'
|
||||||
|
|
||||||
|
package 'vector'
|
||||||
|
|
|
@ -6,3 +6,8 @@
|
||||||
mode '0755'
|
mode '0755'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Stop vector default service:
|
||||||
|
service 'vector' do
|
||||||
|
action :disable
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
deb https://repositories.timber.io/public/vector/deb/ubuntu <%= @distribution %> main
|
||||||
|
|
||||||
|
deb-src https://repositories.timber.io/public/vector/deb/ubuntu <%= @distribution %> main
|
Loading…
Reference in New Issue