Install `prometheus` when finding a newer version.
This commit is contained in:
parent
a8b637a51e
commit
dc6b5a2f01
|
@ -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,28 +25,33 @@ rescue
|
||||||
raise 'Cannot connect to http://github.com.'
|
raise 'Cannot connect to http://github.com.'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Download:
|
|
||||||
TMP = "/tmp/#{prometheus_bin}"
|
|
||||||
|
|
||||||
execute "wget #{prometheus_url} -O #{TMP}"
|
# バージョン確認して、アップデート必要かどうか確認
|
||||||
|
result = run_command("prometheus --version 2>&1 | grep #{tag}", error: false)
|
||||||
|
if result.exit_status != 0
|
||||||
|
# Download:
|
||||||
|
TMP = "/tmp/#{prometheus_bin}"
|
||||||
|
|
||||||
# Install:
|
execute "wget #{prometheus_url} -O #{TMP}"
|
||||||
directory node['prometheus']['storage'] do
|
|
||||||
owner 'root'
|
# Install:
|
||||||
group 'root'
|
directory node['prometheus']['storage'] do
|
||||||
mode '755'
|
owner 'root'
|
||||||
end
|
group 'root'
|
||||||
|
mode '755'
|
||||||
execute "tar zxf #{TMP} -C #{node['prometheus']['storage']} --strip-components 1"
|
end
|
||||||
|
|
||||||
# Change Owner and Permissions:
|
execute "tar zxf #{TMP} -C #{node['prometheus']['storage']} --strip-components 1"
|
||||||
file "#{node['prometheus']['storage']}prometheus" do
|
|
||||||
owner 'root'
|
# Change Owner and Permissions:
|
||||||
group 'root'
|
file "#{node['prometheus']['storage']}prometheus" do
|
||||||
mode '755'
|
owner 'root'
|
||||||
end
|
group 'root'
|
||||||
|
mode '755'
|
||||||
# Create Link
|
end
|
||||||
link "#{node['prometheus']['location']}prometheus" do
|
|
||||||
to "#{node['prometheus']['storage']}prometheus"
|
# Create Link
|
||||||
|
link "#{node['prometheus']['location']}prometheus" do
|
||||||
|
to "#{node['prometheus']['storage']}prometheus"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue