2020-10-24 09:54:58 +00:00
|
|
|
# Create Link
|
|
|
|
link '/etc/prometheus_exporters.d/snmp.yml' do
|
|
|
|
to "#{node['snmp_exporter']['storage']}snmp.yml"
|
|
|
|
end
|
|
|
|
|
2023-02-05 11:40:26 +00:00
|
|
|
# Deploy `systemd` config:
|
|
|
|
remote_file '/etc/systemd/system/snmp_exporter.service' do
|
2020-10-24 09:54:58 +00:00
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
2023-02-05 11:40:26 +00:00
|
|
|
end
|
2020-10-24 09:54:58 +00:00
|
|
|
|
2023-02-05 11:40:26 +00:00
|
|
|
service 'snmp_exporter' do
|
|
|
|
action [:enable, :start]
|
2020-10-24 09:54:58 +00:00
|
|
|
end
|
|
|
|
|
2023-02-05 11:53:27 +00:00
|
|
|
# Deploy `rsyslog` config for `snmp_exporter`:
|
|
|
|
remote_file '/etc/rsyslog.d/30-snmp_exporter.conf' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
|
|
|
|
notifies :restart, 'service[rsyslog]'
|
|
|
|
end
|
|
|
|
|
|
|
|
service 'rsyslog' do
|
|
|
|
action :nothing
|
|
|
|
end
|
|
|
|
|
2023-02-05 12:54:19 +00:00
|
|
|
# Deploy `logrotate` config for `snmp_exporter`:
|
|
|
|
remote_file '/etc/logrotate.d/snmp_exporter' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
2023-02-05 13:00:56 +00:00
|
|
|
# Deploy `vector` config for `snmp_exporter`:
|
|
|
|
remote_file '/etc/vector/snmp_exporter.toml' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
|
|
|
remote_file '/etc/systemd/system/vector-snmp_exporter.service' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '0644'
|
|
|
|
end
|
|
|
|
|
|
|
|
service 'vector-snmp_exporter' do
|
|
|
|
action [:enable, :start]
|
|
|
|
end
|
|
|
|
|
2020-10-24 10:34:01 +00:00
|
|
|
# Deploy `consul` config:
|
|
|
|
remote_file '/etc/consul.d/service-snmp_exporter.json' do
|
2020-11-22 15:52:14 +00:00
|
|
|
owner 'consul'
|
|
|
|
group 'consul'
|
2020-10-24 10:34:01 +00:00
|
|
|
mode '644'
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
notifies :reload, 'service[consul]'
|
2020-10-24 10:34:01 +00:00
|
|
|
end
|
|
|
|
|
2020-11-22 16:42:06 +00:00
|
|
|
# Restart the `reload`:
|
|
|
|
service 'consul' do
|
2020-10-24 09:54:58 +00:00
|
|
|
action :nothing
|
|
|
|
end
|
2020-10-24 15:16:11 +00:00
|
|
|
|
|
|
|
# Deploy /etc/hosts file:
|
|
|
|
template '/etc/promtail/snmp_exporter.yaml' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
|
|
|
|
variables(HOSTNAME: node[:hostname], LOKIENDPOINT: node['promtail']['lokiendpoint'])
|
|
|
|
|
2020-10-25 06:43:50 +00:00
|
|
|
notifies :restart, 'service[promtail-snmp_exporter]'
|
2020-10-24 15:16:11 +00:00
|
|
|
end
|
2020-10-24 15:16:55 +00:00
|
|
|
|
|
|
|
# Deploy the `systemd` configuration:
|
|
|
|
remote_file '/lib/systemd/system/promtail-snmp_exporter.service' do
|
|
|
|
owner 'root'
|
|
|
|
group 'root'
|
|
|
|
mode '644'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Service setting:
|
|
|
|
service 'promtail-snmp_exporter' do
|
|
|
|
action [ :enable, :restart ]
|
|
|
|
end
|