2023-02-05 10:49:14 +00:00
|
|
|
# Deploy the `systemd` configuration:
|
2023-02-05 10:05:42 +00:00
|
|
|
remote_file '/etc/systemd/system/node_exporter.service' do
|
2020-10-12 14:56:41 +00:00
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
2023-02-05 10:05:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
remote_file '/etc/default/node_exporter' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
2020-10-12 14:56:41 +00:00
|
|
|
|
2023-02-05 10:05:42 +00:00
|
|
|
service 'node_exporter' do
|
|
|
|
action [ :enable, :start]
|
2020-10-12 14:56:41 +00:00
|
|
|
end
|
|
|
|
|
2023-02-05 10:20:05 +00:00
|
|
|
# Deploy `rsyslog` config for `node_exporter`:
|
|
|
|
remote_file '/etc/rsyslog.d/30-node_exporter.conf' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
|
|
|
|
notifies :restart, 'service[rsyslog]'
|
|
|
|
end
|
|
|
|
|
|
|
|
service 'rsyslog' do
|
|
|
|
action :nothing
|
|
|
|
end
|
|
|
|
|
2023-02-05 10:43:23 +00:00
|
|
|
# Deploy `logrotate` config for `node_exporter`:
|
|
|
|
remote_file '/etc/logrotate.d/node_exporter' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '0644'
|
|
|
|
end
|
|
|
|
|
2023-02-05 10:49:14 +00:00
|
|
|
# Deploy the `systemd` config for `vector`:
|
|
|
|
remote_file '/etc/vector/node_exporter.toml' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
|
|
|
remote_file '/etc/systemd/system/vector-node_exporter.service' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
|
|
|
service 'vector-node_exporter' do
|
|
|
|
action [ :enable, :start]
|
|
|
|
end
|
|
|
|
|
2020-10-12 14:56:41 +00:00
|
|
|
# Deploy `consul` config for `node_exporter`:
|
|
|
|
remote_file '/etc/consul.d/service-node_exporter.json' do
|
2020-11-22 15:52:14 +00:00
|
|
|
owner 'consul'
|
|
|
|
group 'consul'
|
2020-10-12 14:56:41 +00:00
|
|
|
mode '644'
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
notifies :reload, 'service[consul]'
|
2020-10-12 14:56:41 +00:00
|
|
|
end
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
service 'consul' do
|
2020-10-12 14:56:41 +00:00
|
|
|
action :nothing
|
|
|
|
end
|
|
|
|
|
|
|
|
# Firewall settings here:
|
|
|
|
%w( 9100/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
|