Use `eget` to download and install `consul-template`.

This commit is contained in:
Kazuhiro MUSASHI 2024-06-10 11:45:12 +09:00
parent 4f2aeaac41
commit 6bc876df6f
2 changed files with 4 additions and 9 deletions

View File

@ -1,10 +1,12 @@
# ------------------------------------------- # -------------------------------------------
# Specifying the default settings: # Specifying the default settings:
# ------------------------------------------- # -------------------------------------------
node.reverse_merge!({ node.reverse_merge!({
'consulTemplate' => { 'consulTemplate' => {
'baseUrl' => 'https://releases.hashicorp.com/consul-template/', '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_', 'zipPrefix' => 'consul-template_',
'zipPostfix' => '_linux_amd64.zip', 'zipPostfix' => '_linux_amd64.zip',
'storage' => '/opt/consul-template/consul-template', 'storage' => '/opt/consul-template/consul-template',

View File

@ -5,20 +5,13 @@ consulTemplate_url = "#{node['consulTemplate']['baseUrl']}#{node['consulTemplate
result = run_command('which consul-template', error: false) result = run_command('which consul-template', error: false)
if result.exit_status != 0 if result.exit_status != 0
# Download:
TMP = "/tmp/#{consulTemplate_zip}"
execute "wget #{consulTemplate_url} -O #{TMP}"
directory '/opt/consul-template' do directory '/opt/consul-template' do
owner 'root' owner 'root'
group 'root' group 'root'
mode '0755' mode '0755'
end end
execute "unzip #{TMP} -d /opt/consul-template/" do execute "eget #{consulTemplate_url} --to /opt/consul-template/"
not_if 'test -e /opt/consul-template/consul-template'
end
# Change Owner and Permissions: # Change Owner and Permissions:
file "#{node['consulTemplate']['storage']}" do file "#{node['consulTemplate']['storage']}" do