Merge branch 'consider-version-when-downloading' of kazu634/itamae into master

This commit is contained in:
Kazuhiro MUSASHI 2019-11-08 01:34:02 +09:00 committed by Gitea
commit 4b157c3f5d
5 changed files with 111 additions and 80 deletions

View File

@ -2,6 +2,7 @@
# Calculating the latest `consul-template` version: # Calculating the latest `consul-template` version:
# ------------------------------------------- # -------------------------------------------
download_url = '' download_url = ''
tag_version = ''
begin begin
require 'net/http' require 'net/http'
@ -26,22 +27,26 @@ end
# Main Part # Main Part
# ------------------------------------------- # -------------------------------------------
# Download: # バージョン確認して、アップデート必要かどうか確認
execute "wget #{download_url} -O #{node['consul-template']['tmp_path']}" result = run_command("consul-template --version 2>&1 | grep #{tag_version}", error: false)
if result.exit_status != 0
# Download:
execute "wget #{download_url} -O #{node['consul-template']['tmp_path']}"
# Unzip: # Unzip:
execute "unzip -qo #{node['consul-template']['tmp_path']}" do execute "unzip -qo #{node['consul-template']['tmp_path']}" do
cwd '/opt/consul/bin/' cwd '/opt/consul/bin/'
end end
file '/opt/consul/bin/consul-template' do file '/opt/consul/bin/consul-template' do
owner 'root' owner 'root'
group 'root' group 'root'
mode '755' mode '755'
end end
# Create link: # Create link:
link '/usr/local/bin/consul-template' do link '/usr/local/bin/consul-template' do
user 'root' user 'root'
to '/opt/consul/bin/consul-template' to '/opt/consul/bin/consul-template'
end
end end

View File

@ -2,6 +2,7 @@
# Calculating the latest `consul` version: # Calculating the latest `consul` version:
# ------------------------------------------- # -------------------------------------------
download_url = '' download_url = ''
tag_version = ''
begin begin
require 'net/http' require 'net/http'
@ -26,22 +27,27 @@ end
# Main Part # Main Part
# ------------------------------------------- # -------------------------------------------
# Download: # バージョン確認して、アップデート必要かどうか確認
execute "wget #{download_url} -O #{node['consul']['tmp_path']}" result = run_command("consul version | grep #{tag_version}", error: false)
if result.exit_status != 0
# Download:
execute "wget #{download_url} -O #{node['consul']['tmp_path']}"
# Unzip: # Unzip:
execute "unzip -qo #{node['consul']['tmp_path']}" do execute "unzip -qo #{node['consul']['tmp_path']}" do
cwd '/opt/consul/bin/' cwd '/opt/consul/bin/'
end end
file '/opt/consul/bin/consul' do file '/opt/consul/bin/consul' do
owner 'root' owner 'root'
group 'root' group 'root'
mode '755' mode '755'
end end
# Create link: # Create link:
link '/usr/local/bin/consul' do link '/usr/local/bin/consul' do
user 'root' user 'root'
to '/opt/consul/bin/consul' to '/opt/consul/bin/consul'
end
end end

View File

@ -50,12 +50,17 @@ rescue
raise 'Cannot connect to http://github.com.' raise 'Cannot connect to http://github.com.'
end end
# Download `nginx-build`:
execute "wget #{nginxbuild} -O #{TARBALL}"
execute "tar xf #{TARBALL} && chown webadm:webadm #{NGINXBUILD}" do # バージョン確認して、アップデート必要かどうか確認
result = run_command("/home/webadm/nginx-build/nginx-build --version | grep #{tag_version}", error: false)
if result.exit_status != 0
# Download `nginx-build`:
execute "wget #{nginxbuild} -O #{TARBALL}"
execute "tar xf #{TARBALL} && chown webadm:webadm #{NGINXBUILD}" do
user USER user USER
cwd WORKDIR cwd WORKDIR
end
end end
# Deploy `configure.sh`: # Deploy `configure.sh`:

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,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
# Install:
directory node['prometheus']['storage'] do
owner 'root' owner 'root'
group 'root' group 'root'
mode '755' mode '755'
end end
execute "tar zxf #{TMP} -C #{node['prometheus']['storage']} --strip-components 1" execute "tar zxf #{TMP} -C #{node['prometheus']['storage']} --strip-components 1"
# Change Owner and Permissions: # Change Owner and Permissions:
file "#{node['prometheus']['storage']}prometheus" do file "#{node['prometheus']['storage']}prometheus" do
owner 'root' owner 'root'
group 'root' group 'root'
mode '755' mode '755'
end end
# Create Link # Create Link
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

View File

@ -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