From c13954bfc943b8f4ea3be16908ac9dcf7e7c5f5c Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Wed, 23 Sep 2020 23:39:13 +0900 Subject: [PATCH] Delete `consul-template`. --- cookbooks/consul-template/attributes.rb | 10 ---- cookbooks/consul-template/default.rb | 6 --- cookbooks/consul-template/install.rb | 52 ------------------- cookbooks/consul-template/prerequisites.rb | 14 ----- cookbooks/consul-template/setup.rb | 9 ---- .../consul-template.d/prometheus-targets.tmpl | 2 - .../supervisor/conf.d/prometheus-targets.conf | 8 --- cookbooks/prometheus/prometheus_setup.rb | 16 ------ 8 files changed, 117 deletions(-) delete mode 100644 cookbooks/consul-template/attributes.rb delete mode 100644 cookbooks/consul-template/default.rb delete mode 100644 cookbooks/consul-template/install.rb delete mode 100644 cookbooks/consul-template/prerequisites.rb delete mode 100644 cookbooks/consul-template/setup.rb delete mode 100644 cookbooks/prometheus/files/etc/consul-template.d/prometheus-targets.tmpl delete mode 100644 cookbooks/prometheus/files/etc/supervisor/conf.d/prometheus-targets.conf diff --git a/cookbooks/consul-template/attributes.rb b/cookbooks/consul-template/attributes.rb deleted file mode 100644 index 808ffaa..0000000 --- a/cookbooks/consul-template/attributes.rb +++ /dev/null @@ -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' - } -}) diff --git a/cookbooks/consul-template/default.rb b/cookbooks/consul-template/default.rb deleted file mode 100644 index 69dfe7d..0000000 --- a/cookbooks/consul-template/default.rb +++ /dev/null @@ -1,6 +0,0 @@ -include_recipe './attributes.rb' - -include_recipe './prerequisites.rb' -include_recipe './install.rb' - -include_recipe './setup.rb' diff --git a/cookbooks/consul-template/install.rb b/cookbooks/consul-template/install.rb deleted file mode 100644 index 1172339..0000000 --- a/cookbooks/consul-template/install.rb +++ /dev/null @@ -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 diff --git a/cookbooks/consul-template/prerequisites.rb b/cookbooks/consul-template/prerequisites.rb deleted file mode 100644 index ea061dd..0000000 --- a/cookbooks/consul-template/prerequisites.rb +++ /dev/null @@ -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 diff --git a/cookbooks/consul-template/setup.rb b/cookbooks/consul-template/setup.rb deleted file mode 100644 index 61dc148..0000000 --- a/cookbooks/consul-template/setup.rb +++ /dev/null @@ -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 diff --git a/cookbooks/prometheus/files/etc/consul-template.d/prometheus-targets.tmpl b/cookbooks/prometheus/files/etc/consul-template.d/prometheus-targets.tmpl deleted file mode 100644 index 56232d0..0000000 --- a/cookbooks/prometheus/files/etc/consul-template.d/prometheus-targets.tmpl +++ /dev/null @@ -1,2 +0,0 @@ -- targets:{{range nodes}} - - {{.Address}}:60000{{end}} diff --git a/cookbooks/prometheus/files/etc/supervisor/conf.d/prometheus-targets.conf b/cookbooks/prometheus/files/etc/supervisor/conf.d/prometheus-targets.conf deleted file mode 100644 index 39d8b5e..0000000 --- a/cookbooks/prometheus/files/etc/supervisor/conf.d/prometheus-targets.conf +++ /dev/null @@ -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 diff --git a/cookbooks/prometheus/prometheus_setup.rb b/cookbooks/prometheus/prometheus_setup.rb index 9489e7b..2eb63c3 100644 --- a/cookbooks/prometheus/prometheus_setup.rb +++ b/cookbooks/prometheus/prometheus_setup.rb @@ -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'