Merge pull request #44 from netmanagers/master

fix(debian): add some valid defaults
This commit is contained in:
Nicolas Rodriguez 2020-08-31 18:53:24 +02:00 committed by GitHub
commit a53d228c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 45 deletions

View File

@ -82,11 +82,11 @@ prometheus-archive-install-{{ name }}-file-directory:
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
{%- if grains.kernel|lower == 'linux' and 'config_file' in p.pkg.component[name] %}
{%- if grains.kernel|lower == 'linux' %}
prometheus-archive-install-{{ name }}-managed-service:
file.managed:
- name: {{ p.dir.service }}/{{ name }}.service
- name: {{ p.dir.service }}/{{ p.pkg.component[name]['service'].get('name', name) }}.service
- source: {{ files_switch(['systemd.ini.jinja'],
lookup='prometheus-archive-install-' ~ name ~ '-managed-service'
)
@ -103,7 +103,7 @@ prometheus-archive-install-{{ name }}-managed-service:
group: {{ name }}
workdir: {{ p.dir.var }}/{{ name }}
stop: ''
{%- if name in ('node_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

View File

@ -20,6 +20,8 @@ Arch: {}
Alpine: {}
Debian:
dir:
service: /lib/systemd/system
pkg:
deps:
- cron
@ -31,66 +33,108 @@ Debian:
name: prometheus
alertmanager:
name: prometheus-alertmanager
service:
name: prometheus-alertmanager
args_file: /etc/default/prometheus-alertmanager
apache_exporter:
name: prometheus-apache-exporter
service:
name: prometheus-apache-exporter
args_file: /etc/default/prometheus-apache-exporter
bind_exporter:
name: prometheus-bind-exporter
args_file: /etc/default/prometheus-bind-exporter
bird_exporter:
name: prometheus-bird-exporter
args_file: /etc/default/prometheus-bird-exporter
blackbox_exporter:
name: prometheus-blackbox-exporter
service:
name: prometheus-blackbox-exporter
config_file: /etc/prometheus/blackbox.yml
hacluster_exporter:
name: prometheus-hacluster-exporter
args_file: /etc/default/prometheus-hacluster-exporter
haproxy_exporter:
name: prometheus-haproxy-exporter
args_file: /etc/default/prometheus-haproxy-exporter
homeplug_exporter:
name: prometheus-homeplug-exporter
args_file: /etc/default/prometheus-homeplug-exporter
ipmi_exporter:
name: prometheus-ipmi-exporter
args_file: /etc/default/prometheus-ipmi-exporter
libvirt_exporter:
name: prometheus-libvirt-exporter
args_file: /etc/default/prometheus-libvirt-exporter
mailexporter:
name: prometheus-mailexporter
args_file: /etc/default/prometheus-mailexporter
mongodb_exporter:
name: prometheus-mongodb-exporter
args_file: /etc/default/prometheus-mongodb-exporter
mysqld_exporter:
name: prometheus-mysqld-exporter
service:
name: prometheus-mysqld-exporter
args_file: /etc/default/prometheus-mysqld-exporter
nginx_exporter:
name: prometheus-nginx-exporter
service:
name: prometheus-nginx-exporter
args_file: /etc/default/prometheus-nginx-exporter
nginx_vts_exporter:
name: prometheus-nginx-vts-exporter
args_file: /etc/default/prometheus-nginx-vts-exporter
node_exporter:
name: prometheus-node-exporter
service:
name: prometheus-node-exporter
args_file: /etc/default/prometheus-node-exporter
node_exporter_collectors:
name: prometheus-node-exporter-collectors
args_file: /etc/default/prometheus-node-exporter-collectors
openstack_exporter:
name: prometheus-openstack-exporter
args_file: /etc/default/prometheus-openstack-exporter
pgbouncer_exporter:
name: prometheus-pgbouncer-exporter
args_file: /etc/default/prometheus-pgbouncer-exporter
postfix_exporter:
name: prometheus-postfix-exporter
args_file: /etc/default/prometheus-postfix-exporter
postgres_exporter:
name: prometheus-postgres-exporter
service:
name: prometheus-postgres-exporter
args_file: /etc/default/prometheus-postgres-exporter
process_exporter:
name: prometheus-process-exporter
args_file: /etc/default/prometheus-process-exporter
pushgateway:
name: prometheus-pushgateway
args_file: /etc/default/prometheus-pushgateway
snmp_exporter:
name: prometheus-snmp-exporter
args_file: /etc/default/prometheus-snmp-exporter
sql_exporter:
name: prometheus-sql-exporter
args_file: /etc/default/prometheus-sql-exporter
squid_exporter:
name: prometheus-squid-exporter
args_file: /etc/default/prometheus-squid-exporter
tplink_plug_exporter:
name: prometheus-tplink-plug-exporter
args_file: /etc/default/prometheus-tplink-plug-exporter
trafficserver_exporter:
name: prometheus-trafficserver-exporter
args_file: /etc/default/prometheus-trafficserver-exporter
varnish_exporter:
name: prometheus-varnish-exporter
args_file: /etc/default/prometheus-varnish-exporter
xmpp_alerts:
name: prometheus-xmpp-alerts
args_file: /etc/default/prometheus-xmpp-alerts
exporters:
node_exporter:

View File

@ -3,6 +3,17 @@
control 'prometheus components' do
title 'should be installed'
case platform[:family]
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
# it { should be_installed } # not available on amazonlinux?
# end
@ -39,7 +50,7 @@ control 'prometheus components' do
it { should exist }
its('group') { should eq 'prometheus' }
end
describe file('/usr/lib/systemd/system/prometheus.service') do
describe file("#{service_dir}/prometheus.service") do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
@ -56,7 +67,7 @@ control 'prometheus components' do
it { should exist }
its('group') { should eq 'alertmanager' }
end
describe file('/usr/lib/systemd/system/alertmanager.service') do
describe file("#{service_dir}/#{alert_manager_service}.service") do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
@ -73,7 +84,7 @@ control 'prometheus components' do
it { should exist }
its('group') { should eq 'node_exporter' }
end
describe file('/usr/lib/systemd/system/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' }

View File

@ -1,15 +1,53 @@
# frozen_string_literal: true
control 'prometheus services' do
control 'services with a consistent service name on each distro' do
title 'should be running'
describe service('node_exporter') do
distro_services =
case platform[:family]
when 'debian'
%w[
prometheus
prometheus-alertmanager
prometheus-node-exporter
prometheus-blackbox-exporter
]
else
%w[
prometheus
alertmanager
node_exporter
blackbox_exporter
]
end
distro_services.each do |service|
describe service(service) do
it { should be_enabled }
it { should be_running }
end
end
# blackbox_exporter port
describe port(9115) do
it { should be_listening }
end
end
control 'services with any service name we want to give them' do
title 'should be running'
# if we set a service name in the pillar,
# the formula should work, no matter what it is or the
# install method we choose
describe service('my-fancy-consul-exporter-service') do
it { should be_enabled }
it { should be_running }
end
# node_exporter port
describe port(9100) do
# consul_exporter port
describe port(9107) do
it { should be_listening }
end
end

View File

@ -3,18 +3,30 @@
control 'prometheus services' do
title 'should be running'
service =
services =
case platform[:family]
when 'redhat'
'node_exporter'
%w[
node_exporter
prometheus
blackbox_exporter
alertmanager
]
else
'prometheus-node-exporter'
%w[
prometheus
prometheus-node-exporter
prometheus-blackbox-exporter
prometheus-alertmanager
]
end
services.each do |service|
describe service(service) do
it { should be_enabled }
it { should be_running }
end
end
# prometheus-node-exporter port
describe port(9100) do

View File

@ -13,6 +13,8 @@ prometheus:
- prometheus
- alertmanager
- node_exporter
- blackbox_exporter
- consul_exporter
# - memcached_exporter # not in upstream repo, only archive
exporters:
@ -79,25 +81,26 @@ 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:
source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
service:
# name: prometheus-node-exporter
args:
web.listen-address: ":9110"
# collector.textfile.directory: /var/tmp/node_exporter
blackbox_exporter:
service:
args:
web.listen-address: ":9115"
config_file: /opt/prometheus/blackbox_exporter-v0.14.0/blackbox.yml
consul_exporter:
service:
# This is to test that any fancy name we use, will work in archive mode
name: my-fancy-consul-exporter-service
prometheus:
service:
args:

View File

@ -12,7 +12,6 @@ prometheus:
- alertmanager
- node_exporter
- blackbox_exporter
# - memcached_exporter # not in upstream repo, only archive
exporters:
node_exporter:
@ -72,20 +71,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'
{% if grains['os_family'] == 'Debian' %}
service:
name: prometheus-alertmanager
{% endif %}
node_exporter:
version: v0.18.1
archive:
@ -94,9 +79,11 @@ prometheus:
args:
web.listen-address: ":9110"
# collector.textfile.directory: /var/tmp/node_exporter
{% if grains['os_family'] == 'Debian' %}
name: prometheus-node-exporter
{% endif %}
blackbox_exporter:
service:
args:
web.listen-address: ":9115"
prometheus:
service: