Install `node_exporter` when finding a newer version.
This commit is contained in:
parent
45fe078188
commit
a8b637a51e
|
@ -1,6 +1,9 @@
|
||||||
node_exporter_url = ''
|
node_exporter_url = ''
|
||||||
node_exporter_bin = ''
|
node_exporter_bin = ''
|
||||||
|
|
||||||
|
tag = ''
|
||||||
|
vtag = ''
|
||||||
|
|
||||||
# Calculate the Download URL:
|
# Calculate the Download URL:
|
||||||
begin
|
begin
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
|
@ -21,28 +24,32 @@ rescue
|
||||||
raise 'Cannot connect to http://github.com.'
|
raise 'Cannot connect to http://github.com.'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Download:
|
# バージョン確認して、アップデート必要かどうか確認
|
||||||
TMP = "/tmp/#{node_exporter_bin}"
|
result = run_command("node_exporter --version 2>&1 | grep #{tag}", error: false)
|
||||||
|
if result.exit_status != 0
|
||||||
|
# Download:
|
||||||
|
TMP = "/tmp/#{node_exporter_bin}"
|
||||||
|
|
||||||
execute "wget #{node_exporter_url} -O #{TMP}"
|
execute "wget #{node_exporter_url} -O #{TMP}"
|
||||||
|
|
||||||
# Install:
|
# Install:
|
||||||
directory node['node_exporter']['storage'] do
|
directory node['node_exporter']['storage'] do
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode '755'
|
mode '755'
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "tar zxf #{TMP} -C #{node['node_exporter']['storage']} --strip-components 1"
|
execute "tar zxf #{TMP} -C #{node['node_exporter']['storage']} --strip-components 1"
|
||||||
|
|
||||||
# Change Owner and Permissions:
|
# Change Owner and Permissions:
|
||||||
file "#{node['node_exporter']['storage']}node_exporter" do
|
file "#{node['node_exporter']['storage']}node_exporter" do
|
||||||
owner 'root'
|
owner 'root'
|
||||||
group 'root'
|
group 'root'
|
||||||
mode '755'
|
mode '755'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create Link
|
# Create Link
|
||||||
link "#{node['node_exporter']['location']}node_exporter" do
|
link "#{node['node_exporter']['location']}node_exporter" do
|
||||||
to "#{node['node_exporter']['storage']}node_exporter"
|
to "#{node['node_exporter']['storage']}node_exporter"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue