2020-05-14 01:27:23 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
control 'prometheus components' do
|
|
|
|
title 'should be installed'
|
|
|
|
|
2020-08-25 16:30:05 +02:00
|
|
|
case platform[:family]
|
|
|
|
when 'debian'
|
|
|
|
service_dir = '/lib/systemd/system'
|
|
|
|
alert_manager_service = 'prometheus-alertmanager'
|
2020-08-25 19:13:57 +02:00
|
|
|
node_exporter_service = 'prometheus-node-exporter'
|
2020-08-25 16:30:05 +02:00
|
|
|
else
|
|
|
|
service_dir = '/usr/lib/systemd/system'
|
|
|
|
alert_manager_service = 'alertmanager'
|
2020-08-25 19:13:57 +02:00
|
|
|
node_exporter_service = 'node_exporter'
|
2020-08-25 16:30:05 +02:00
|
|
|
end
|
2020-08-25 00:55:09 +02:00
|
|
|
|
2020-05-14 01:27:23 +02:00
|
|
|
# describe package('cron') do
|
|
|
|
# it { should be_installed } # not available on amazonlinux?
|
|
|
|
# end
|
|
|
|
describe group('prometheus') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe user('prometheus') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe group('alertmanager') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe user('alertmanager') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe group('node_exporter') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe user('node_exporter') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
describe directory('/var/lib/prometheus') do
|
|
|
|
it { should exist }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe directory('/opt/prometheus/prometheus-v2.22.1') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe file('/opt/prometheus/prometheus-v2.22.1/prometheus') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe directory('/var/lib/prometheus/prometheus') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'prometheus' }
|
|
|
|
end
|
2020-08-25 00:55:09 +02:00
|
|
|
describe file("#{service_dir}/prometheus.service") do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe directory('/opt/prometheus/alertmanager-v0.21.0') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe file('/opt/prometheus/alertmanager-v0.21.0/amtool') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe directory('/var/lib/prometheus/alertmanager') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'alertmanager' }
|
|
|
|
end
|
2020-08-25 16:30:05 +02:00
|
|
|
describe file("#{service_dir}/#{alert_manager_service}.service") do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe directory('/opt/prometheus/node_exporter-v1.0.1') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
2020-11-11 14:23:27 +01:00
|
|
|
describe file('/opt/prometheus/node_exporter-v1.0.1/node_exporter') do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe directory('/var/lib/prometheus/node_exporter') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'node_exporter' }
|
|
|
|
end
|
2020-08-25 19:13:57 +02:00
|
|
|
describe file("#{service_dir}/#{node_exporter_service}.service") do
|
2020-05-14 01:27:23 +02:00
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
|
|
|
describe file('/usr/local/sbin/alertmanager') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe file('/usr/local/sbin/amtool') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe file('/usr/local/sbin/node_exporter') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe file('/usr/local/sbin/prometheus') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe file('/usr/local/sbin/promtool') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'root' }
|
|
|
|
end
|
|
|
|
describe file('/etc/prometheus/prometheus.yml') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'prometheus' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
|
|
|
describe file('/etc/prometheus/alertmanager.yml') do
|
|
|
|
it { should exist }
|
|
|
|
its('group') { should eq 'alertmanager' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
|
|
|
end
|