Install `consul-template` when finding a newer version.

This commit is contained in:
Kazuhiro MUSASHI 2019-11-05 23:39:25 +08:00
parent e0820892d4
commit 45fe078188
1 changed files with 20 additions and 15 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