2019-03-03 08:50:49 +00:00
|
|
|
# Create `/etc/prometheus.d/`:
|
2020-09-26 08:02:51 +00:00
|
|
|
%w(/etc/prometheus.d).each do |d|
|
2019-03-03 08:50:49 +00:00
|
|
|
directory d do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '0755'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Deploy `prometheus` files:
|
|
|
|
remote_file '/etc/prometheus.d/prometheus.yml' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Deploy `supervisor` configuration for `prometheus`:
|
|
|
|
remote_file '/etc/supervisor/conf.d/prometheus.conf' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
|
|
|
|
notifies :restart, 'service[supervisor]'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Depoy `consul` service configuration for `prometheus`:
|
|
|
|
remote_file '/etc/consul.d/service-prometheus.json' do
|
2020-11-22 15:52:14 +00:00
|
|
|
owner 'consul'
|
|
|
|
group 'consul'
|
2019-03-03 08:50:49 +00:00
|
|
|
mode '644'
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
notifies :reload, 'service[consul]'
|
2019-03-03 08:50:49 +00:00
|
|
|
end
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
# Restart the `consul`:
|
|
|
|
service 'consul' do
|
2019-03-03 08:50:49 +00:00
|
|
|
action :nothing
|
|
|
|
end
|
|
|
|
|
|
|
|
# Firewall settings here:
|
|
|
|
%w( 9090/tcp ).each do |p|
|
|
|
|
execute "ufw allow #{p}" do
|
|
|
|
user 'root'
|
|
|
|
|
|
|
|
not_if "LANG=c ufw status | grep #{p}"
|
|
|
|
|
|
|
|
notifies :run, 'execute[ufw reload-or-enable]'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
execute 'ufw reload-or-enable' do
|
|
|
|
user 'root'
|
|
|
|
command 'LANG=C ufw reload | grep skipping && ufw --force enable || exit 0'
|
|
|
|
|
|
|
|
action :nothing
|
|
|
|
end
|