Delete `consul-template`.

This commit is contained in:
Kazuhiro MUSASHI 2020-09-23 23:39:13 +09:00
parent 40e1b4005e
commit c13954bfc9
8 changed files with 0 additions and 117 deletions

View File

@ -1,10 +0,0 @@
# -------------------------------------------
# Specifying the default settings:
# -------------------------------------------
node.reverse_merge!({
'consul-template' => {
'base_binary_url' => 'https://releases.hashicorp.com/consul-template/',
'arch' => node['kernel']['machine'] =~ /x86_64/ ? 'amd64' : '386',
'tmp_path' => '/tmp/itamae_tmp/consul-template.zip'
}
})

View File

@ -1,6 +0,0 @@
include_recipe './attributes.rb'
include_recipe './prerequisites.rb'
include_recipe './install.rb'
include_recipe './setup.rb'

View File

@ -1,52 +0,0 @@
# -------------------------------------------
# Calculating the latest `consul-template` version:
# -------------------------------------------
download_url = ''
tag_version = ''
begin
require 'net/http'
uri = URI.parse('https://releases.hashicorp.com/consul-template/')
Timeout.timeout(3) do
response = Net::HTTP.get_response(uri)
if response.body =~ /consul-template_(\d+\.\d+\.\d+)/
tag_version = $1
download_url = \
"#{node['consul-template']['base_binary_url']}#{tag_version}/consul-template_#{tag_version}_linux_#{node['consul-template']['arch']}.zip"
end
end
rescue
# Abort the chef client process:
raise 'Cannot connect to https://releases.hashicorp.com/consul-template/'
end
# -------------------------------------------
# Main Part
# -------------------------------------------
# バージョン確認して、アップデート必要かどうか確認
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:
execute "unzip -qo #{node['consul-template']['tmp_path']}" do
cwd '/opt/consul/bin/'
end
file '/opt/consul/bin/consul-template' do
owner 'root'
group 'root'
mode '755'
end
# Create link:
link '/usr/local/bin/consul-template' do
user 'root'
to '/opt/consul/bin/consul-template'
end
end

View File

@ -1,14 +0,0 @@
# Ensure that `unzip` and `dnsmasq` are available:
%w( unzip ).each do |p|
package p do
action :install
end
end
%w( /opt/consul/bin ).each do |d|
directory d do
owner 'root'
group 'root'
mode '755'
end
end

View File

@ -1,9 +0,0 @@
# `consul-template`-related paths:
%w( /etc/consul-template.d ).each do |d|
directory d do
owner 'root'
group 'root'
mode '755'
end
end

View File

@ -1,2 +0,0 @@
- targets:{{range nodes}}
- {{.Address}}:60000{{end}}

View File

@ -1,8 +0,0 @@
[program:prometheus-targets]
command=/usr/local/bin/consul-template -consul-addr 127.0.0.1:8500 -template "/etc/consul-template.d/prometheus-targets.tmpl:/etc/prometheus.d/targets/targets.yml"
stdout_logfile=/var/log/supervisor/prometheus-targets.log
redirect_stderr=true
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=5
autorestart=true
stopsignal=INT

View File

@ -21,22 +21,6 @@ remote_file '/etc/prometheus.d/targets/targets.yml' do
mode '644'
end
# Deploy template file for `consul-template` generating `prometheus` target file:
remote_file '/etc/consul-template.d/prometheus-targets.tmpl' do
owner 'root'
group 'root'
mode '644'
end
# Deploy `supervisor` configuration for `prometheus-targets`, genarating `prometheus` targets:
remote_file '/etc/supervisor/conf.d/prometheus-targets.conf' do
owner 'root'
group 'root'
mode '644'
notifies :restart, 'service[supervisor]'
end
# Deploy `supervisor` configuration for `prometheus`:
remote_file '/etc/supervisor/conf.d/prometheus.conf' do
owner 'root'