Install `prometheus` when finding a newer version.

This commit is contained in:
Kazuhiro MUSASHI 2019-11-06 00:02:51 +08:00
parent a8b637a51e
commit dc6b5a2f01
1 changed files with 30 additions and 22 deletions

View File

@ -1,6 +1,9 @@
prometheus_url = '' prometheus_url = ''
prometheus_bin = '' prometheus_bin = ''
vtag = ''
tag = ''
# Calculate the Download URL: # Calculate the Download URL:
begin begin
require 'net/http' require 'net/http'
@ -22,6 +25,10 @@ rescue
raise 'Cannot connect to http://github.com.' raise 'Cannot connect to http://github.com.'
end end
# バージョン確認して、アップデート必要かどうか確認
result = run_command("prometheus --version 2>&1 | grep #{tag}", error: false)
if result.exit_status != 0
# Download: # Download:
TMP = "/tmp/#{prometheus_bin}" TMP = "/tmp/#{prometheus_bin}"
@ -47,3 +54,4 @@ end
link "#{node['prometheus']['location']}prometheus" do link "#{node['prometheus']['location']}prometheus" do
to "#{node['prometheus']['storage']}prometheus" to "#{node['prometheus']['storage']}prometheus"
end end
end