Merge pull request #43 from n-rodriguez/fix/debian

Fix node_exporter service not restarted on archive fresh install
This commit is contained in:
Imran Iqbal 2020-08-24 23:21:33 +01:00 committed by GitHub
commit 97584e6bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 276 additions and 23 deletions

View File

@ -91,6 +91,8 @@ jobs:
# - env: INSTANCE=default-fedora-31-3000-3-py3 # - env: INSTANCE=default-fedora-31-3000-3-py3
- env: INSTANCE=default-opensuse-leap-152-3000-3-py3 - env: INSTANCE=default-opensuse-leap-152-3000-3-py3
- env: INSTANCE=default-amazonlinux-2-3000-3-py3 - env: INSTANCE=default-amazonlinux-2-3000-3-py3
- env: INSTANCE=default-debian-10-3001-py3
- env: INSTANCE=default-debian-9-3001-py3
# - env: INSTANCE=default-ubuntu-1804-3000-3-py2 # - env: INSTANCE=default-ubuntu-1804-3000-3-py2
# - env: INSTANCE=default-ubuntu-1604-3000-3-py2 # - env: INSTANCE=default-ubuntu-1604-3000-3-py2
# - env: INSTANCE=default-arch-base-latest-3000-3-py2 # - env: INSTANCE=default-arch-base-latest-3000-3-py2

View File

@ -42,6 +42,14 @@ platforms:
driver: driver:
image: saltimages/salt-master-py3:amazonlinux-2 image: saltimages/salt-master-py3:amazonlinux-2
## SALT `3001`
- name: debian-10-3001-py3
driver:
image: saltimages/salt-3001-py3:debian-10
- name: debian-9-3001-py3
driver:
image: saltimages/salt-3001-py3:debian-9
## SALT `3000.3` ## SALT `3000.3`
- name: debian-10-3000-3-py3 - name: debian-10-3000-3-py3
driver: driver:

View File

@ -43,7 +43,6 @@ prometheus:
environ_file: /etc/default/prometheus-alertmanager.sh environ_file: /etc/default/prometheus-alertmanager.sh
environ: {} environ: {}
service: service:
name: alertmanager
args: args:
config.file: /etc/prometheus/alertmanager.yml config.file: /etc/prometheus/alertmanager.yml
storage.path: /var/lib/alertmanager storage.path: /var/lib/alertmanager
@ -133,7 +132,6 @@ prometheus:
config_file: /etc/prometheus/node_exporter.yml config_file: /etc/prometheus/node_exporter.yml
config: {} config: {}
service: service:
name: prometheus-node-exporter
args: args:
collector.textfile.directory: /var/tmp/node_exporter collector.textfile.directory: /var/tmp/node_exporter
archive: archive:
@ -153,7 +151,6 @@ prometheus:
environ_file: /etc/default/prometheus.sh environ_file: /etc/default/prometheus.sh
environ: {} environ: {}
service: service:
name: prometheus
args: args:
config.file: /etc/prometheus/prometheus.yml config.file: /etc/prometheus/prometheus.yml
storage.tsdb.path: /var/lib/prometheus/data storage.tsdb.path: /var/lib/prometheus/data

View File

@ -12,14 +12,14 @@ include:
{%- for name in p.wanted.component %} {%- for name in p.wanted.component %}
{%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %} {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
{%- set service_name = p.pkg.component[name]['service']['get'](name, {}).get('name', name) %} {%- set service_name = p.pkg.component[name]['service'].get('name', name) %}
prometheus-service-running-{{ name }}-unmasked: prometheus-service-running-{{ name }}-unmasked:
service.unmasked: service.unmasked:
- name: {{ service_name }} - name: {{ service_name }}
- onlyif: - onlyif:
- {{ grains.kernel|lower == 'linux' }} - {{ grains.kernel|lower == 'linux' }}
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1 - systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
- require_in: - require_in:
- service: prometheus-service-running-{{ name }} - service: prometheus-service-running-{{ name }}
- require: - require:
@ -33,7 +33,7 @@ prometheus-service-running-{{ name }}:
- reload_modules: true - reload_modules: true
{%- endif %} {%- endif %}
service.running: service.running:
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1 - onlyif: systemctl list-unit-files | grep {{ service_name }} >/dev/null 2>&1
- enable: True - enable: True
- require: - require:
- sls: {{ sls_config_file }} - sls: {{ sls_config_file }}

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
control 'prometheus services' do
title 'should be running'
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

View File

@ -1,23 +1,24 @@
# frozen_string_literal: true # frozen_string_literal: true
case platform[:family]
when 'redhat'
packages = %w[
prometheus2
alertmanager
node_exporter
]
when 'debian'
packages = %w[
prometheus
prometheus-alertmanager
prometheus-node-exporter
]
end
control 'prometheus packages' do control 'prometheus packages' do
title 'should be installed' title 'should be installed'
packages =
case platform[:family]
when 'redhat'
%w[
prometheus2
alertmanager
node_exporter
]
when 'debian'
%w[
prometheus
prometheus-alertmanager
prometheus-node-exporter
]
end
packages.each do |p| packages.each do |p|
describe package(p) do describe package(p) do
it { should be_installed } it { should be_installed }

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
control 'prometheus services' do
title 'should be running'
service =
case platform[:family]
when 'redhat'
'node_exporter'
else
'prometheus-node-exporter'
end
describe service(service) do
it { should be_enabled }
it { should be_running }
end
# prometheus-node-exporter port
describe port(9100) do
it { should be_listening }
end
end

View File

@ -1 +0,0 @@
../../../pillar.example

View File

@ -0,0 +1,201 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
prometheus:
wanted:
clientlibs:
- golang
- haskell
- rust
component:
# List components (ie, exporters) using underscores and
# removing the 'prometheus' prefix
- prometheus
- alertmanager
- node_exporter
# - memcached_exporter # not in upstream repo, only archive
exporters:
node_exporter:
textfile_collectors_dependencies: []
textfile_collectors:
ipmitool:
enable: false
remove: false
pkg: ipmitool
smartmon:
enable: false
remove: false
pkg: smartmontools
bash_pkg: bash
smartctl: /usr/sbin/smartctl
pkg:
use_upstream_repo: false
use_upstream_archive: true
clientlibs:
# https://prometheus.io/docs/instrumenting/clientlibs
# no bash & perl client tarballs are available
golang:
version: v1.6.0
component:
# If you use OS packages in Debian's family, components should have
# a 'name' variable stating the name of the package (it's generally
# something like `prometheus-component-with-dashes-replacing-underscores`
# ie,
# node_exporter:
# name: prometheus-node-exporter
#
# See prometheus/osfamilymap.yaml for more examples
alertmanager:
config:
# yamllint disable-line rule:line-length
# ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
global:
smtp_smarthost: 'localhost:25'
smtp_from: 'alertmanager@example.org'
smtp_auth_username: 'alertmanager'
smtp_auth_password: "multiline\nmysecret"
smtp_hello: "host.example.org"
slack_api_url: "http://mysecret.example.com/"
http_config:
proxy_url: 'http://127.0.0.1:1025'
route:
group_by: ['alertname', 'cluster', 'service']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: team-X-mails
routes:
- match_re:
service: ^(foo1|foo2|baz)$
receiver: team-X-mails
routes:
- match:
severity: critical
receiver: team-X-mails
receivers:
- name: 'team-X-mails'
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
prometheus:
service:
args:
web.listen-address: 0.0.0.0:9090
config:
# yamllint disable-line rule:line-length
# ref https://raw.githubusercontent.com/prometheus/prometheus/release-2.10/config/testdata/conf.good.yml
# my global config
global:
# Set the scrape interval to every 15 seconds. Default is every 1 minute
scrape_interval: 15s
# Evaluate rules every 15 seconds. The default is every 1 minute
evaluation_interval: 15s
# scrape_timeout is set to the global default (10s)
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager1:9093
- alertmanager2:9093
- alertmanager3:9093
# Load rules once and periodically evaluate them according to the global
# 'evaluation_interval'
rule_files:
- "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries
# scraped from this config
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'
static_configs:
- targets: ['localhost:9090']
- job_name: pushgateway
scrape_interval: 5s
honor_labels: true
static_configs:
- targets: ['pushgateway:9091']
- job_name: 'blackbox'
# https://github.com/prometheus/blackbox_exporter#prometheus-configuration
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response
static_configs:
- targets:
- http://prometheus.io # Target to probe with http
- https://prometheus.io # Target to probe with https
- http://example.com:8080 # Target to probe with http on port 8080
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: '127.0.0.1:9115' # real hostname and port
pushgateway:
version: v0.8.0
archive:
source_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
service:
args:
web.listen-address: ":9091"
web.telemetry-path: "/metrics"
linux:
# 'Alternatives system' priority: zero disables (default)
# yamllint disable-line rule:braces
altpriority: {{ range(1, 9100000) | random }}
tofs:
# The files_switch key serves as a selector for alternative
# directories under the formula files directory. See TOFS pattern
# doc for more info
# Note: Any value not evaluated by `config.get` will be used literally
# This can be used to set custom paths, as many levels deep as required
files_switch:
- any/path/can/be/used/here
- id
- osfinger
- os
- os_family
# All aspects of path/file resolution are customisable using the options below
# This is unnecessary in most cases; there are sensible defaults
# path_prefix: prometheus_alt
# dirs:
# files: files_alt
# default: default_alt
source_files:
prometheus-config-file-file-managed:
- 'alt_config.yml.jinja'
prometheus-archive-install-managed-service:
- 'alt_systemd.ini.jinja'

View File

@ -81,15 +81,22 @@ prometheus:
- channel: '#my-channel' - channel: '#my-channel'
image_url: 'http://some.img.com/img.png' image_url: 'http://some.img.com/img.png'
{% if grains['os_family'] == 'Debian' %}
service:
name: prometheus-alertmanager
{% endif %}
node_exporter: node_exporter:
version: v0.18.1 version: v0.18.1
archive: archive:
source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424 source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
service: service:
name: prometheus-node-exporter
args: args:
web.listen-address: ":9110" web.listen-address: ":9110"
# collector.textfile.directory: /var/tmp/node_exporter # collector.textfile.directory: /var/tmp/node_exporter
{% if grains['os_family'] == 'Debian' %}
name: prometheus-node-exporter
{% endif %}
prometheus: prometheus:
service: service: