fix(archive): add config file to service only if defined
This commit is contained in:
parent
a5d4d03f8d
commit
a5b44c812b
@ -103,7 +103,7 @@ prometheus-archive-install-{{ name }}-managed-service:
|
|||||||
group: {{ name }}
|
group: {{ name }}
|
||||||
workdir: {{ p.dir.var }}/{{ name }}
|
workdir: {{ p.dir.var }}/{{ name }}
|
||||||
stop: ''
|
stop: ''
|
||||||
{%- if name in ('node_exporter', 'consul_exporter') %}
|
{%- if name in ('node_exporter', 'consul_exporter') or 'config_file' not in p.pkg.component[name] %}
|
||||||
start: {{ p.pkg.component[name]['path'] }}/{{ name }}
|
start: {{ p.pkg.component[name]['path'] }}/{{ name }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }} # noqa 204
|
start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }} # noqa 204
|
||||||
|
@ -7,9 +7,11 @@ control 'prometheus components' do
|
|||||||
when 'debian'
|
when 'debian'
|
||||||
service_dir = '/lib/systemd/system'
|
service_dir = '/lib/systemd/system'
|
||||||
alert_manager_service = 'prometheus-alertmanager'
|
alert_manager_service = 'prometheus-alertmanager'
|
||||||
|
node_exporter_service = 'prometheus-node-exporter'
|
||||||
else
|
else
|
||||||
service_dir = '/usr/lib/systemd/system'
|
service_dir = '/usr/lib/systemd/system'
|
||||||
alert_manager_service = 'alertmanager'
|
alert_manager_service = 'alertmanager'
|
||||||
|
node_exporter_service = 'node_exporter'
|
||||||
end
|
end
|
||||||
|
|
||||||
# describe package('cron') do
|
# describe package('cron') do
|
||||||
@ -82,7 +84,7 @@ control 'prometheus components' do
|
|||||||
it { should exist }
|
it { should exist }
|
||||||
its('group') { should eq 'node_exporter' }
|
its('group') { should eq 'node_exporter' }
|
||||||
end
|
end
|
||||||
describe file("#{service_dir}/node_exporter.service") do
|
describe file("#{service_dir}/#{node_exporter_service}.service") do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
its('group') { should eq 'root' }
|
its('group') { should eq 'root' }
|
||||||
its('mode') { should cmp '0644' }
|
its('mode') { should cmp '0644' }
|
||||||
|
@ -1,39 +1,31 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
control 'services with a consistent service name across distros' do
|
|
||||||
title 'should be running'
|
|
||||||
|
|
||||||
# we forced node_exporter's service name to `node_exporter` in the pillar,
|
|
||||||
# so its name will be the same across distros for this test
|
|
||||||
describe service('node_exporter') do
|
|
||||||
it { should be_enabled }
|
|
||||||
it { should be_running }
|
|
||||||
end
|
|
||||||
|
|
||||||
# node_exporter port
|
|
||||||
describe port(9100) do
|
|
||||||
it { should be_listening }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
control 'services with a consistent service name on each distro' do
|
control 'services with a consistent service name on each distro' do
|
||||||
title 'should be running'
|
title 'should be running'
|
||||||
|
|
||||||
# if we don't set a service name in the pillar,
|
distro_services =
|
||||||
# its name will be the same on each distro, no matter what the
|
|
||||||
# install method we choose
|
|
||||||
|
|
||||||
distro_service =
|
|
||||||
case platform[:family]
|
case platform[:family]
|
||||||
when 'debian'
|
when 'debian'
|
||||||
'prometheus-blackbox-exporter'
|
%w[
|
||||||
|
prometheus
|
||||||
|
prometheus-alertmanager
|
||||||
|
prometheus-node-exporter
|
||||||
|
prometheus-blackbox-exporter
|
||||||
|
]
|
||||||
else
|
else
|
||||||
'blackbox_exporter'
|
%w[
|
||||||
|
prometheus
|
||||||
|
alertmanager
|
||||||
|
node_exporter
|
||||||
|
blackbox_exporter
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
describe service(distro_service) do
|
distro_services.each do |service|
|
||||||
it { should be_enabled }
|
describe service(service) do
|
||||||
it { should be_running }
|
it { should be_enabled }
|
||||||
|
it { should be_running }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# blackbox_exporter port
|
# blackbox_exporter port
|
||||||
|
@ -81,15 +81,6 @@ prometheus:
|
|||||||
email_configs:
|
email_configs:
|
||||||
- to: 'team-X+alerts@example.org'
|
- to: 'team-X+alerts@example.org'
|
||||||
|
|
||||||
inhibit_rules:
|
|
||||||
- name: opsGenie-receiver
|
|
||||||
opsgenie_configs:
|
|
||||||
- api_key: mysecret
|
|
||||||
- name: slack-receiver
|
|
||||||
slack_configs:
|
|
||||||
- channel: '#my-channel'
|
|
||||||
image_url: 'http://some.img.com/img.png'
|
|
||||||
|
|
||||||
node_exporter:
|
node_exporter:
|
||||||
version: v0.18.1
|
version: v0.18.1
|
||||||
archive:
|
archive:
|
||||||
|
Loading…
Reference in New Issue
Block a user