Skip to content

Commit

Permalink
fix(archive): add config file to service only if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbertoli committed Aug 29, 2020
1 parent a5d4d03 commit a5b44c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 37 deletions.
2 changes: 1 addition & 1 deletion prometheus/archive/install.sls
Expand Up @@ -103,7 +103,7 @@ prometheus-archive-install-{{ name }}-managed-service:
group: {{ name }}
workdir: {{ p.dir.var }}/{{ name }}
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 }}
{%- else %}
start: {{ p.pkg.component[name]['path'] }}/{{ name }} --config.file {{ p.pkg.component[name]['config_file'] }} # noqa 204
Expand Down
4 changes: 3 additions & 1 deletion test/integration/default/controls/archive_spec.rb
Expand Up @@ -7,9 +7,11 @@
when 'debian'
service_dir = '/lib/systemd/system'
alert_manager_service = 'prometheus-alertmanager'
node_exporter_service = 'prometheus-node-exporter'
else
service_dir = '/usr/lib/systemd/system'
alert_manager_service = 'alertmanager'
node_exporter_service = 'node_exporter'
end

# describe package('cron') do
Expand Down Expand Up @@ -82,7 +84,7 @@
it { should exist }
its('group') { should eq 'node_exporter' }
end
describe file("#{service_dir}/node_exporter.service") do
describe file("#{service_dir}/#{node_exporter_service}.service") do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
Expand Down
44 changes: 18 additions & 26 deletions test/integration/default/controls/service_spec.rb
@@ -1,39 +1,31 @@
# 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
title 'should be running'

# if we don't set a service name in the pillar,
# its name will be the same on each distro, no matter what the
# install method we choose

distro_service =
distro_services =
case platform[:family]
when 'debian'
'prometheus-blackbox-exporter'
%w[
prometheus
prometheus-alertmanager
prometheus-node-exporter
prometheus-blackbox-exporter
]
else
'blackbox_exporter'
%w[
prometheus
alertmanager
node_exporter
blackbox_exporter
]
end

describe service(distro_service) do
it { should be_enabled }
it { should be_running }
distro_services.each do |service|
describe service(service) do
it { should be_enabled }
it { should be_running }
end
end

# blackbox_exporter port
Expand Down
9 changes: 0 additions & 9 deletions test/salt/pillar/default.sls
Expand Up @@ -81,15 +81,6 @@ prometheus:
email_configs:
- 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:
version: v0.18.1
archive:
Expand Down

0 comments on commit a5b44c8

Please sign in to comment.