From 6bc876df6f1bbaa1c5144caa7389dd750444fefb Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 10 Jun 2024 11:45:12 +0900 Subject: [PATCH] Use `eget` to download and install `consul-template`. --- cookbooks/consul-template/attributes.rb | 4 +++- cookbooks/consul-template/install.rb | 9 +-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cookbooks/consul-template/attributes.rb b/cookbooks/consul-template/attributes.rb index cb6f58c..63eb081 100644 --- a/cookbooks/consul-template/attributes.rb +++ b/cookbooks/consul-template/attributes.rb @@ -1,10 +1,12 @@ # ------------------------------------------- # Specifying the default settings: # ------------------------------------------- + + node.reverse_merge!({ 'consulTemplate' => { 'baseUrl' => 'https://releases.hashicorp.com/consul-template/', - 'version' => '0.25.2', + 'version' => `curl -s https://releases.hashicorp.com/consul-template/ | htmlq -t 'a' | grep consul-template | head -n 1 | sed -e 's/^[^_]*_//g'`.chomp!, 'zipPrefix' => 'consul-template_', 'zipPostfix' => '_linux_amd64.zip', 'storage' => '/opt/consul-template/consul-template', diff --git a/cookbooks/consul-template/install.rb b/cookbooks/consul-template/install.rb index 7c0b01a..d603766 100644 --- a/cookbooks/consul-template/install.rb +++ b/cookbooks/consul-template/install.rb @@ -5,20 +5,13 @@ consulTemplate_url = "#{node['consulTemplate']['baseUrl']}#{node['consulTemplate result = run_command('which consul-template', error: false) if result.exit_status != 0 - # Download: - TMP = "/tmp/#{consulTemplate_zip}" - - execute "wget #{consulTemplate_url} -O #{TMP}" - directory '/opt/consul-template' do owner 'root' group 'root' mode '0755' end - execute "unzip #{TMP} -d /opt/consul-template/" do - not_if 'test -e /opt/consul-template/consul-template' - end + execute "eget #{consulTemplate_url} --to /opt/consul-template/" # Change Owner and Permissions: file "#{node['consulTemplate']['storage']}" do