refactor(all): align to template-formula; add clientlibs feature

BREAKING CHANGE: The data dictionary is simplified and expanded.
Retest your states and update pillar data accordingly.
For developer convenience, clientlibs states were introduced.
See pillar.example, defaults.yaml, and docs/README.
This commit is contained in:
N 2020-05-14 00:27:23 +01:00
parent 97d7517c8e
commit ce5b7712c9
87 changed files with 2618 additions and 1792 deletions

View File

@ -25,17 +25,14 @@ stages:
- name: 'release'
if: 'branch = master AND type != pull_request'
jobs:
allow_failures:
- env: Lint_rubocop
fast_finish: true
include:
## Define the test stage that runs the linters (and testing matrix, if applicable)
# Run all of the linters in a single job (except `rubocop`)
# Run all of the linters in a single job
- language: 'node_js'
node_js: 'lts/*'
env: 'Lint'
name: 'Lint: salt-lint, yamllint, shellcheck & commitlint'
name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint'
before_install: 'skip'
script:
# Install and run `salt-lint`
@ -46,6 +43,9 @@ jobs:
# Need at least `v1.17.0` for the `yaml-files` setting
- pip install --user yamllint>=1.17.0
- yamllint -s .
# Install and run `rubocop`
- gem install rubocop
- rubocop -d
# Run `shellcheck` (already pre-installed in Travis)
- shellcheck --version
- git ls-files -- '*.sh' '*.bash' '*.ksh'
@ -54,50 +54,43 @@ jobs:
- npm i -D @commitlint/config-conventional
@commitlint/travis-cli
- commitlint-travis
# Run the `rubocop` linter in a separate job that is allowed to fail
# Once these lint errors are fixed, this can be merged into a single job
- language: node_js
node_js: lts/*
env: Lint_rubocop
name: 'Lint: rubocop'
before_install: skip
script:
# Install and run `rubocop`
- gem install rubocop
- rubocop -d
# Interrogate
# - pip install --user interrogate
# - interrogate .
## Define the rest of the matrix based on Kitchen testing
# Make sure the instances listed below match up with
# the `platforms` defined in `kitchen.yml`
- env: INSTANCE=default-debian-10-master-py3
- env: INSTANCE=default-ubuntu-1804-master-py3
# - env: INSTANCE=default-centos-8-master-py3
# - env: INSTANCE=default-fedora-31-master-py3
# env: INSTANCE=repo-ubuntu-1804-master-py3
- env: INSTANCE=repo-centos-8-master-py3
- env: INSTANCE=default-fedora-31-master-py3
# - env: INSTANCE=default-opensuse-leap-151-master-py3
# - env: INSTANCE=default-amazonlinux-2-master-py3
- env: INSTANCE=default-amazonlinux-2-master-py3
# - env: INSTANCE=default-debian-10-3000-2-py3
# - env: INSTANCE=default-debian-9-3000-2-py3
# - env: INSTANCE=default-ubuntu-1804-3000-2-py3
# - env: INSTANCE=default-centos-8-3000-2-py3
# - env: INSTANCE=default-centos-7-3000-2-py3
# - env: INSTANCE=default-fedora-31-3000-2-py3
# - env: INSTANCE=default-opensuse-leap-151-3000-2-py3
# - env: INSTANCE=default-amazonlinux-2-3000-2-py3
# - env: INSTANCE=default-ubuntu-1804-3000-2-py2
# - env: INSTANCE=default-ubuntu-1604-3000-2-py2
# - env: INSTANCE=arch-arch-base-latest-3000-2-py2
# - env: INSTANCE=default-debian-10-2019-2-py3
- env: INSTANCE=default-debian-9-2019-2-py3
- env: INSTANCE=default-ubuntu-1804-2019-2-py3
# - env: INSTANCE=default-debian-9-2019-2-py3
# - env: INSTANCE=default-ubuntu-1804-2019-2-py3
# - env: INSTANCE=default-ubuntu-1604-2019-2-py3
# - env: INSTANCE=default-centos-8-2019-2-py3
# - env: INSTANCE=default-centos-7-2019-2-py3
# - env: INSTANCE=default-fedora-31-2019-2-py3
# - env: INSTANCE=default-opensuse-leap-151-2019-2-py3
# - env: INSTANCE=default-centos-7-2019-2-py2
# - env: INSTANCE=default-amazonlinux-2-2019-2-py3
# - env: INSTANCE=default-arch-base-latest-2019-2-py2
# - env: INSTANCE=default-fedora-30-2018-3-py3
- env: INSTANCE=default-debian-9-2018-3-py2
# - env: INSTANCE=default-ubuntu-1604-2018-3-py2
# - env: INSTANCE=default-centos-7-2018-3-py2
# - env: INSTANCE=default-opensuse-leap-151-2018-3-py2
# - env: INSTANCE=default-amazonlinux-1-2018-3-py2
# - env: INSTANCE=default-arch-base-latest-2018-3-py2
# - env: INSTANCE=default-debian-8-2017-7-py2
- env: INSTANCE=default-ubuntu-1604-2017-7-py2
# - env: INSTANCE=default-centos-6-2017-7-py2
# - env: INSTANCE=default-fedora-30-2017-7-py2
# - env: INSTANCE=default-opensuse-leap-151-2017-7-py2
# - env: INSTANCE=default-amazonlinux-1-2017-7-py2
# - env: INSTANCE=default-arch-base-latest-2017-7-py2
# - env: INSTANCE=default-centos-6-2019-2-py2
# - env: INSTANCE=default-amazonlinux-1-2019-2-py2
- env: INSTANCE=default-arch-base-latest-2019-2-py2
## Define the release stage that runs `semantic-release`
- stage: 'release'

View File

@ -12,6 +12,9 @@ ignore: |
node_modules/
test/**/states/**/*.sls
.kitchen/
bin/kitchen
prometheus/osfamilymap.yaml
pillar.example
yaml-files:
# Default settings
@ -30,7 +33,7 @@ rules:
line-length:
# Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
max: 88
max: 98
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true

View File

@ -4,12 +4,7 @@ This list is sorted by the number of commits per contributor in _descending_ ord
Avatar|Contributor|Contributions
:-:|---|:-:
<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/10231489?v=4' width='36' height='36' alt='@myii'>|[@myii](https://github.com/myii)|43
<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/13322818?v=4' width='36' height='36' alt='@noelmcloughlin'>|[@noelmcloughlin](https://github.com/noelmcloughlin)|21
<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1920805?v=4' width='36' height='36' alt='@alxwr'>|[@alxwr](https://github.com/alxwr)|17
<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1800660?v=4' width='36' height='36' alt='@aboe76'>|[@aboe76](https://github.com/aboe76)|6
<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/6086064?v=4' width='36' height='36' alt='@mgomersbach'>|[@mgomersbach](https://github.com/mgomersbach)|1
<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/13322818?v=4' width='36' height='36' alt='@noelmcloughlin'>|[@noelmcloughlin](https://github.com/noelmcloughlin)|1
---
Auto-generated by a [forked version](https://github.com/myii/maintainer) of [gaocegege/maintainer](https://github.com/gaocegege/maintainer) on 2019-12-22.

View File

@ -1,12 +1,9 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
# SECTION: Owner(s) for everything in the repo, unless a later match takes precedence
# **************************************************************************
# *** NO GLOBAL OWNER(S) SPECIFIED ***
# *** Ideally this will be defined for a healthy, well-maintained repo ***
# **************************************************************************
# FILE PATTERN OWNER(S)
* @NONE
* @alxwr
* @noelmcloughlin
# SECTION: Owner(s) for specific directories
# FILE PATTERN OWNER(S)

12
FORMULA
View File

@ -1,9 +1,9 @@
name: prometheus
os: FreeBSD
os_family: FreeBSD
version: 3.3.0
os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS
version: 0.2.2
release: 1
minimum_version: 2016.11
summary: Prometheus formula
description: Formula to set up Prometheus
minimum_version: 2019.2
summary: prometheus formula
description: Formula to install prometheus and configure it
top_level_dir: prometheus

View File

@ -1,4 +1,4 @@
Copyright (c) 2019 Salt Stack Formulas
Copyright (c) 2014 Salt Stack Formulas
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -18,11 +18,8 @@ if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, '\
'so this binstub cannot run. Replace `bin/bundle` by running '\
'`bundle binstubs bundler --force`, then run this command again.'
)
abort('Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, & run cmd again')
end
end

View File

@ -15,21 +15,72 @@ This list is sorted by the number of commits per contributor in *descending* ord
- Contributions
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/10231489?v=4' width='36' height='36' alt='@myii'>`
- `@myii <https://github.com/myii>`_
- 43
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/13322818?v=4' width='36' height='36' alt='@noelmcloughlin'>`
- `@noelmcloughlin <https://github.com/noelmcloughlin>`_
- 21
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1920805?v=4' width='36' height='36' alt='@alxwr'>`
- `@alxwr <https://github.com/alxwr>`_
- 17
- 155
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1800660?v=4' width='36' height='36' alt='@aboe76'>`
- `@aboe76 <https://github.com/aboe76>`_
- 22
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/242396?v=4' width='36' height='36' alt='@javierbertoli'>`
- `@javierbertoli <https://github.com/javierbertoli>`_
- 15
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars3.githubusercontent.com/u/3433835?v=4' width='36' height='36' alt='@n-rodriguez'>`
- `@n-rodriguez <https://github.com/n-rodriguez>`_
- 8
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/1396878?v=4' width='36' height='36' alt='@gravyboat'>`
- `@gravyboat <https://github.com/gravyboat>`_
- 6
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/6086064?v=4' width='36' height='36' alt='@mgomersbach'>`
- `@mgomersbach <https://github.com/mgomersbach>`_
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1920805?v=4' width='36' height='36' alt='@alxwr'>`
- `@alxwr <https://github.com/alxwr>`_
- 5
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars3.githubusercontent.com/u/52996?v=4' width='36' height='36' alt='@daks'>`
- `@daks <https://github.com/daks>`_
- 5
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars3.githubusercontent.com/u/4542588?v=4' width='36' height='36' alt='@evvers'>`
- `@evvers <https://github.com/evvers>`_
- 4
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/3374962?v=4' width='36' height='36' alt='@nmadhok'>`
- `@nmadhok <https://github.com/nmadhok>`_
- 3
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/16338056?v=4' width='36' height='36' alt='@vutny'>`
- `@vutny <https://github.com/vutny>`_
- 2
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/29522418?v=4' width='36' height='36' alt='@k-hamza'>`
- `@k-hamza <https://github.com/k-hamza>`_
- 2
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/528061?v=4' width='36' height='36' alt='@puneetk'>`
- `@puneetk <https://github.com/puneetk>`_
- 2
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/3536289?v=4' width='36' height='36' alt='@andygabby'>`
- `@andygabby <https://github.com/andygabby>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/1269218?v=4' width='36' height='36' alt='@Jokipii'>`
- `@Jokipii <https://github.com/Jokipii>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars3.githubusercontent.com/u/5306980?v=4' width='36' height='36' alt='@johnkeates'>`
- `@johnkeates <https://github.com/johnkeates>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/611471?v=4' width='36' height='36' alt='@duk3luk3'>`
- `@duk3luk3 <https://github.com/duk3luk3>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars3.githubusercontent.com/u/3075069?v=4' width='36' height='36' alt='@marco-m'>`
- `@marco-m <https://github.com/marco-m>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/13322818?v=4' width='36' height='36' alt='@noelmcloughlin'>`
- `@noelmcloughlin <https://github.com/noelmcloughlin>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars2.githubusercontent.com/u/91293?v=4' width='36' height='36' alt='@whiteinge'>`
- `@whiteinge <https://github.com/whiteinge>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/22272?v=4' width='36' height='36' alt='@sroegner'>`
- `@sroegner <https://github.com/sroegner>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars1.githubusercontent.com/u/117961?v=4' width='36' height='36' alt='@babilen5'>`
- `@babilen5 <https://github.com/babilen5>`_
- 1
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/2205993?v=4' width='36' height='36' alt='@GMAzrael'>`
- `@GMAzrael <https://github.com/GMAzrael>`_
- 1
----
Auto-generated by a `forked version <https://github.com/myii/maintainer>`_ of `gaocegege/maintainer <https://github.com/gaocegege/maintainer>`_ on 2019-12-22.
Auto-generated by a `forked version <https://github.com/myii/maintainer>`_ of `gaocegege/maintainer <https://github.com/gaocegege/maintainer>`_ on 2019-05-31.

View File

@ -1,235 +0,0 @@
Changelog
=========
`3.3.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.2.0...v3.3.0>`_ (2019-12-22)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **pillar.example:** reset ``use_upstream_archive`` to get tests passing [skip ci] (\ `978ccc2 <https://github.com/saltstack-formulas/prometheus-formula/commit/978ccc208045136dddea44dc59754872f688a9cb>`_\ )
* test fix for bug 24 (\ `341fff3 <https://github.com/saltstack-formulas/prometheus-formula/commit/341fff36ead5fce94c25c0ba8011a15d76f26de6>`_\ )
* **release.config.js:** use full commit hash in commit link [skip ci] (\ `cab6e29 <https://github.com/saltstack-formulas/prometheus-formula/commit/cab6e29d8b29c700035694c35b20e8250ecb2ef1>`_\ )
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* **gemfile:** restrict ``train`` gem version until upstream fix [skip ci] (\ `a51e532 <https://github.com/saltstack-formulas/prometheus-formula/commit/a51e532992b69571a1f5ffa486f98aed4ddf87e0>`_\ )
* **kitchen:** use ``debian-10-master-py3`` instead of ``develop`` [skip ci] (\ `6ee835c <https://github.com/saltstack-formulas/prometheus-formula/commit/6ee835cab4a1dca30c9b7888587c68368c53dee1>`_\ )
* **kitchen:** use ``develop`` image until ``master`` is ready (\ ``amazonlinux``\ ) [skip ci] (\ `42ee683 <https://github.com/saltstack-formulas/prometheus-formula/commit/42ee683c44d1bc7035b9ce325e8ad7d0c35b45da>`_\ )
* **kitchen+travis:** upgrade matrix after ``2019.2.2`` release [skip ci] (\ `044553e <https://github.com/saltstack-formulas/prometheus-formula/commit/044553ea8f51fc3af64fe3fd4b9fca8c3b58f2df>`_\ )
* **travis:** apply changes from build config validation [skip ci] (\ `bf4022e <https://github.com/saltstack-formulas/prometheus-formula/commit/bf4022ec1ac489dc875c02e84a547a7a6c245cb8>`_\ )
* **travis:** opt-in to ``dpl v2`` to complete build config validation [skip ci] (\ `0867508 <https://github.com/saltstack-formulas/prometheus-formula/commit/086750884d14bc07ae466dd8247b99c01dbc1766>`_\ )
* **travis:** quote pathspecs used with ``git ls-files`` [skip ci] (\ `d9c9386 <https://github.com/saltstack-formulas/prometheus-formula/commit/d9c93860385303ae89025431da7a83d48c5a6adf>`_\ )
* **travis:** run ``shellcheck`` during lint job [skip ci] (\ `7ea6967 <https://github.com/saltstack-formulas/prometheus-formula/commit/7ea6967ca7d6c41f99ef4831715b894d9c7c751d>`_\ )
* **travis:** update ``salt-lint`` config for ``v0.0.10`` [skip ci] (\ `1415c13 <https://github.com/saltstack-formulas/prometheus-formula/commit/1415c137854f19e34e4a79d74f1bb2b25770ee0c>`_\ )
* **travis:** use ``major.minor`` for ``semantic-release`` version [skip ci] (\ `9b4d5af <https://github.com/saltstack-formulas/prometheus-formula/commit/9b4d5aff64b0657303c7186c5f5a49d02039f35f>`_\ )
* **travis:** use build config validation (beta) [skip ci] (\ `0d0af0d <https://github.com/saltstack-formulas/prometheus-formula/commit/0d0af0df317c67924d0b8dc75d9dbf8e7a3a9535>`_\ )
Features
^^^^^^^^
* **osfamilymap.yaml:** add Gentoo support (\ `b87e8f4 <https://github.com/saltstack-formulas/prometheus-formula/commit/b87e8f437c51c81bb7543ad27b49dea48ff36203>`_\ )
Performance Improvements
^^^^^^^^^^^^^^^^^^^^^^^^
* **travis:** improve ``salt-lint`` invocation [skip ci] (\ `36ccdc4 <https://github.com/saltstack-formulas/prometheus-formula/commit/36ccdc4416d58952865ef60e7b94d122f09c6cde>`_\ )
`3.2.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.1.2...v3.2.0>`_ (2019-10-17)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **args:** allow boolean arguments (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/39dacf0>`_\ )
* **examples:** fixed pillar.example (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/464a186>`_\ )
* **node_exporter:** allow standalone use of node_exporter (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/a0d8ad4>`_\ )
* **package:** use correct node exporter package name in Debian (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/a4fd589>`_\ )
* **readme:** removed already gone prometheus.exporters from README.rst (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/07d6209>`_\ )
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* merge travis matrix, add ``salt-lint`` & ``rubocop`` to ``lint`` job (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/9def915>`_\ )
Documentation
^^^^^^^^^^^^^
* **contributing:** remove to use org-level file instead [skip ci] (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/fabcc4a>`_\ )
* **readme:** update link to ``CONTRIBUTING`` [skip ci] (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/da2a5aa>`_\ )
Features
^^^^^^^^
* **freebsd:** support for FreeBSD (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/871da35>`_\ )
* **textfile_collectors:** added IPMI textfile collector (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/d731309>`_\ )
* **textfile_collectors:** added smartmon textfile collector (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/7b2f5ce>`_\ )
* **textfile_collectors:** added support for textfile collectors (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/930552d>`_\ )
`3.1.2 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.1.1...v3.1.2>`_ (2019-10-10)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **clean.sls:** fix ``salt-lint`` errors (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/8056339>`_\ )
* **install.sls:** fix ``salt-lint`` errors (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/51f5485>`_\ )
* **install.sls:** fix ``salt-lint`` errors (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/173bc4f>`_\ )
* **install.sls:** fix ``salt-lint`` errors (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/85c7fce>`_\ )
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* merge travis matrix, add ``salt-lint`` & ``rubocop`` to ``lint`` job (\ ` <https://github.com/saltstack-formulas/prometheus-formula/commit/569328b>`_\ )
`3.1.1 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.1.0...v3.1.1>`_ (2019-10-07)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **config:** cope with aberrant service names (\ `0a33842 <https://github.com/saltstack-formulas/prometheus-formula/commit/0a33842>`_\ )
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* use ``dist: bionic`` & apply ``opensuse-leap-15`` SCP error workaround (\ `3dc6e12 <https://github.com/saltstack-formulas/prometheus-formula/commit/3dc6e12>`_\ )
* **kitchen:** change ``log_level`` to ``debug`` instead of ``info`` (\ `af666db <https://github.com/saltstack-formulas/prometheus-formula/commit/af666db>`_\ )
* **kitchen:** install required packages to bootstrapped ``opensuse`` [skip ci] (\ `3332493 <https://github.com/saltstack-formulas/prometheus-formula/commit/3332493>`_\ )
* **kitchen:** use bootstrapped ``opensuse`` images until ``2019.2.2`` [skip ci] (\ `a624dd8 <https://github.com/saltstack-formulas/prometheus-formula/commit/a624dd8>`_\ )
* **kitchen+travis:** replace EOL pre-salted images (\ `0895d81 <https://github.com/saltstack-formulas/prometheus-formula/commit/0895d81>`_\ )
* **platform:** add ``arch-base-latest`` (commented out for now) [skip ci] (\ `6221888 <https://github.com/saltstack-formulas/prometheus-formula/commit/6221888>`_\ )
* **yamllint:** add rule ``empty-values`` & use new ``yaml-files`` setting (\ `1784b34 <https://github.com/saltstack-formulas/prometheus-formula/commit/1784b34>`_\ )
`3.1.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.0.1...v3.1.0>`_ (2019-08-17)
------------------------------------------------------------------------------------------------------------
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* **kitchen+travis:** modify matrix to include ``develop`` platform (\ `fc0f5b6 <https://github.com/saltstack-formulas/prometheus-formula/commit/fc0f5b6>`_\ )
Features
^^^^^^^^
* **yamllint:** include for this repo and apply rules throughout (\ `07dbfc8 <https://github.com/saltstack-formulas/prometheus-formula/commit/07dbfc8>`_\ )
`3.0.1 <https://github.com/saltstack-formulas/prometheus-formula/compare/v3.0.0...v3.0.1>`_ (2019-06-28)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **alternatives:** fix requisite (\ `8c410d7 <https://github.com/saltstack-formulas/prometheus-formula/commit/8c410d7>`_\ )
`3.0.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v2.0.0...v3.0.0>`_ (2019-06-23)
------------------------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **example:** fix pillar.example formatting (\ `a13dd03 <https://github.com/saltstack-formulas/prometheus-formula/commit/a13dd03>`_\ )
* **repo:** use_upstream_repo corrections; separate users state (\ `eda47f7 <https://github.com/saltstack-formulas/prometheus-formula/commit/eda47f7>`_\ )
* **service:** ensure service file is removed on clean (\ `c735a6d <https://github.com/saltstack-formulas/prometheus-formula/commit/c735a6d>`_\ )
* **suse:** bypass salt alternatives.install errors (\ `1a890e5 <https://github.com/saltstack-formulas/prometheus-formula/commit/1a890e5>`_\ )
* **systemd:** ensure systemd detects new service (\ `149dd81 <https://github.com/saltstack-formulas/prometheus-formula/commit/149dd81>`_\ )
Features
^^^^^^^^
* **archives:** support for archives file format (\ `1f86f4a <https://github.com/saltstack-formulas/prometheus-formula/commit/1f86f4a>`_\ )
* **archives:** support for various prometheus archives (\ `3ec910e <https://github.com/saltstack-formulas/prometheus-formula/commit/3ec910e>`_\ )
* **archives:** user managementX (\ `d43033a <https://github.com/saltstack-formulas/prometheus-formula/commit/d43033a>`_\ )
* **linux:** alternatives support & updated unit tests (\ `36b3e62 <https://github.com/saltstack-formulas/prometheus-formula/commit/36b3e62>`_\ )
Tests
^^^^^
* **centos:** verified on CentosOS (\ `731198d <https://github.com/saltstack-formulas/prometheus-formula/commit/731198d>`_\ )
* **inspec:** expand unittests for archive format (\ `b074bd3 <https://github.com/saltstack-formulas/prometheus-formula/commit/b074bd3>`_\ )
* **inspec:** fix tests (\ `4092fb4 <https://github.com/saltstack-formulas/prometheus-formula/commit/4092fb4>`_\ )
BREAKING CHANGES
^^^^^^^^^^^^^^^^
* **repo:** The formula has been refactored to accomodate multiple packages,
archives, users, and repos. Update your pillars and top states
* **archives:** the parameter ``pkg`` is now a dictionary. References
to ``prometheus.pkg`` should be changed to ``prometheus.pkg.name``.
`2.0.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v1.2.0...v2.0.0>`_ (2019-06-22)
------------------------------------------------------------------------------------------------------------
Features
^^^^^^^^
* **repository:** add support for pkgrepo.managed (\ `907f9a6 <https://github.com/saltstack-formulas/prometheus-formula/commit/907f9a6>`_\ )
BREAKING CHANGES
^^^^^^^^^^^^^^^^
* **repository:** the variable 'pkg' was renamed 'pkg.name',
update your pillars
`1.2.0 <https://github.com/saltstack-formulas/prometheus-formula/compare/v1.1.0...v1.2.0>`_ (2019-06-05)
------------------------------------------------------------------------------------------------------------
Features
^^^^^^^^
* **macos:** basic package and group handling (\ `e6a8b0c <https://github.com/saltstack-formulas/prometheus-formula/commit/e6a8b0c>`_\ )
`1.1.0 <https://github.com/alxwr/prometheus-formula/compare/v1.0.0...v1.1.0>`_ (2019-04-30)
-----------------------------------------------------------------------------------------------
Bug Fixes
^^^^^^^^^
* **FreeBSD:** elegantly prevent service hang (\ `a7fad98 <https://github.com/alxwr/prometheus-formula/commit/a7fad98>`_\ ), closes `/github.com/saltstack/salt/issues/44848#issuecomment-487016414 <https://github.com//github.com/saltstack/salt/issues/44848/issues/issuecomment-487016414>`_
Features
^^^^^^^^
* **args:** handle service arguments the same way (\ `94078fe <https://github.com/alxwr/prometheus-formula/commit/94078fe>`_\ )
* **exporters:** added node_exporter (\ `34ada49 <https://github.com/alxwr/prometheus-formula/commit/34ada49>`_\ )
1.0.0 (2019-04-25)
------------------
Continuous Integration
^^^^^^^^^^^^^^^^^^^^^^
* **travis:** use structure of template-formula (\ `88d3f3e <https://github.com/alxwr/prometheus-formula/commit/88d3f3e>`_\ )
Features
^^^^^^^^
* **prometheus:** basic setup based on template-formula (\ `b9b7cc0 <https://github.com/alxwr/prometheus-formula/commit/b9b7cc0>`_\ )

186
docs/CONTRIBUTING.rst Normal file
View File

@ -0,0 +1,186 @@
.. _contributing:
How to contribute
=================
This document will eventually outline all aspects of guidance to make your contributing experience a fruitful and enjoyable one.
What it already contains is information about *commit message formatting* and how that directly affects the numerous automated processes that are used for this repo.
It also covers how to contribute to this *formula's documentation*.
.. contents:: **Table of Contents**
Overview
--------
Submitting a pull request is more than just code!
To achieve a quality product, the *tests* and *documentation* need to be updated as well.
An excellent pull request will include these in the changes, wherever relevant.
Commit message formatting
-------------------------
Since every type of change requires making Git commits,
we will start by covering the importance of ensuring that all of your commit
messages are in the correct format.
Automation of multiple processes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This formula uses `semantic-release <https://github.com/semantic-release/semantic-release>`_ for automating numerous processes such as bumping the version number appropriately, creating new tags/releases and updating the changelog.
The entire process relies on the structure of commit messages to determine the version bump, which is then used for the rest of the automation.
Full details are available in the upstream docs regarding the `Angular Commit Message Conventions <https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines>`_.
The key factor is that the first line of the commit message must follow this format:
.. code-block::
type(scope): subject
* E.g. ``docs(contributing): add commit message formatting instructions``.
Besides the version bump, the changelog and release notes are formatted accordingly.
So based on the example above:
..
.. raw:: html
<h3>Documentation</h3>
* **contributing:** add commit message formatting instructions
* The ``type`` translates into a ``Documentation`` sub-heading.
* The ``(scope):`` will be shown in bold text without the brackets.
* The ``subject`` follows the ``scope`` as standard text.
Linting commit messages in Travis CI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This formula uses `commitlint <https://github.com/conventional-changelog/commitlint>`_ for checking commit messages during CI testing.
This ensures that they are in accordance with the ``semantic-release`` settings.
For more details about the default settings, refer back to the ``commitlint`` `reference rules <https://conventional-changelog.github.io/commitlint/#/reference-rules>`_.
Relationship between commit type and version bump
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This formula applies some customisations to the defaults, as outlined in the table below,
based upon the `type <https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type>`_ of the commit:
.. list-table::
:name: commit-type-vs-version-bump
:header-rows: 1
:stub-columns: 0
:widths: 1,2,3,1,1
* - Type
- Heading
- Description
- Bump (default)
- Bump (custom)
* - ``build``
- Build System
- Changes related to the build system
-
-
* - ``chore``
-
- Changes to the build process or auxiliary tools and libraries such as
documentation generation
-
-
* - ``ci``
- Continuous Integration
- Changes to the continuous integration configuration
-
-
* - ``docs``
- Documentation
- Documentation only changes
-
- 0.0.1
* - ``feat``
- Features
- A new feature
- 0.1.0
-
* - ``fix``
- Bug Fixes
- A bug fix
- 0.0.1
-
* - ``perf``
- Performance Improvements
- A code change that improves performance
- 0.0.1
-
* - ``refactor``
- Code Refactoring
- A code change that neither fixes a bug nor adds a feature
-
- 0.0.1
* - ``revert``
- Reverts
- A commit used to revert a previous commit
-
- 0.0.1
* - ``style``
- Styles
- Changes that do not affect the meaning of the code (white-space,
formatting, missing semi-colons, etc.)
-
- 0.0.1
* - ``test``
- Tests
- Adding missing or correcting existing tests
-
- 0.0.1
Use ``BREAKING CHANGE`` to trigger a ``major`` version change
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Adding ``BREAKING CHANGE`` to the footer of the extended description of the commit message will **always** trigger a ``major`` version change, no matter which type has been used.
This will be appended to the changelog and release notes as well.
To preserve good formatting of these notes, the following format is prescribed:
* ``BREAKING CHANGE: <explanation in paragraph format>.``
An example of that:
.. code-block:: git
...
BREAKING CHANGE: With the removal of all of the `.sls` files under
`template package`, this formula no longer supports the installation of
packages.
Semantic release formulas
-------------------------
These formulas are already compatible with semantic-release:
* `bind-formula <https://github.com/saltstack-formulas/bind-formula>`_
* `cert-formula <https://github.com/saltstack-formulas/cert-formula>`_
* `chrony-formula <https://github.com/saltstack-formulas/chrony-formula>`_
* `collectd-formula <https://github.com/saltstack-formulas/collectd-formula>`_
* `fail2ban-formula <https://github.com/saltstack-formulas/fail2ban-formula>`_
* `keepalived-formula <https://github.com/saltstack-formulas/keepalived-formula>`_
* `nginx-formula <https://github.com/saltstack-formulas/nginx-formula>`_
* `postgres-formula <https://github.com/saltstack-formulas/postgres-formula>`_
* `prometheus-formula <https://github.com/saltstack-formulas/prometheus-formula>`_
* `rkhunter-formula <https://github.com/saltstack-formulas/rkhunter-formula>`_
* `salt-formula <https://github.com/saltstack-formulas/salt-formula>`_
* `syslog-ng-formula <https://github.com/saltstack-formulas/syslog-ng-formula>`_
* `systemd-formula <https://github.com/saltstack-formulas/systemd-formula>`_
* `ufw-formula <https://github.com/saltstack-formulas/ufw-formula>`_
* `vault-formula <https://github.com/saltstack-formulas/vault-formula>`_
Documentation
-------------
`Documentation contributing guidelines <CONTRIBUTING_DOCS.rst>`_

View File

@ -0,0 +1,96 @@
.. _contributing_docs:
Contributing documentation
==========================
|docs|
.. |docs| image:: https://readthedocs.org/projects/docs/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://template-formula.readthedocs.io/en/latest/?badge=latest
Toolchain
^^^^^^^^^
The documentation for this formula is written in
`reStructuredText <https://en.wikipedia.org/wiki/ReStructuredText>`_
(also known as RST, ReST, or reST).
It is built by
`Sphinx <https://en.wikipedia.org/wiki/Sphinx_(documentation_generator)>`_
and hosted on
`Read the Docs <https://en.wikipedia.org/wiki/Read_the_Docs>`_.
Adding a new page
^^^^^^^^^^^^^^^^^
Adding a new page involves two steps:
#. Use the
:ref:`provided page template <saltstack_formulas_rst_page_template>`
to create a new page.
#. Add the page name under the ``toctree`` list in ``index.rst``.
a. Do not just append it to the list.
#. Select the best place where it fits within the overall documentation.
SaltStack-Formulas' RST page template
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. _saltstack_formulas_rst_page_template
Use the following template when creating a new page.
This ensures consistency across the documentation for this formula.
The heading symbols have been selected in accordance to the output rendered by the
`Markdown to reStructuredText converter <https://github.com/miyakogi/m2r#restrictions>`_
we are using for some of the pages of this documentation.
.. code-block:: rst
.. _template:
[Page title]
============
[Introductory paragraph]
.. contents:: **Table of Contents**
[Heading 2]
-----------
[Heading 3]
^^^^^^^^^^^
[Heading 4]
~~~~~~~~~~~
[Heading 5]
"""""""""""
[Heading 6]
###########
#. The first line is an anchor that can be used to link back to (the top of)
this file.
a. Change this to be the lowercase version of the file name.
#. Do not include the ``.rst`` file extension.
#. Use hyphens (``-``) instead of spaces or non-letter characters.
#. Change the ``[Page title]`` accordingly, matching the same number of equals
signs (``=``) underneath.
#. Change the ``[Introductory paragraph]`` to be a short summary of the page
content.
Use no more than three paragraphs for this.
#. Leave the ``..contents:: **Table of Contents**`` line as it is.
#. Use the remaining headings as required to break up the page content.
a. You will rarely need to use beyond ``[Heading 4]``.
#. Again, no single heading should have more than about three paragraphs of
content before the next heading or sub-heading is used.
Obviously, it is not necessary to follow the steps in the order above.
For example, it is usually easier to write the ``[Introductory paragraph]``
at the end.

View File

@ -1,7 +1,9 @@
.. _readme:
prometheus-formula
================
==================
Formula to manage Prometheus on GNU/Linux and MacOS.
|img_travis| |img_sr|
@ -13,30 +15,32 @@ prometheus-formula
:alt: Semantic Release
:scale: 100%
:target: https://github.com/semantic-release/semantic-release
Manage Prometheus on MacOS, GNU/Linux and FreeBSD.
.. contents:: **Table of Contents**
:depth: 1
General notes
-------------
See the full `SaltStack Formulas installation and usage instructions
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_. If you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section
<https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas>`_. If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``, which contains the currently released version. This formula is versioned according to `Semantic Versioning <http://semver.org/>`_. See `Formula Versioning Section <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning>`_ for more details.
If you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``,
which contains the currently released version. This formula is versioned according to `Semantic Versioning <http://semver.org/>`_.
Special notes
-------------
See `Formula Versioning Section <https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning>`_ for more details.
None.
Contributing to this repo
-------------------------
**Commit message formatting is significant!!**
Please see `How to contribute <https://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst>`_ for more details.
Please see :ref:`How to contribute <CONTRIBUTING>` for more details.
Available states
----------------
Available metastates
--------------------
.. contents::
:local:
@ -46,86 +50,112 @@ Available states
*Meta-state (This is a state that includes other states)*.
This installs the prometheus package,
manages the prometheus configuration file and then
starts the associated prometheus service.
This installs from prometheus solution.
``prometheus.archive``
^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus from archive file only.
This state will install prometheus components on MacOS and GNU/Linux from archive.
``prometheus.archive.alternatives``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``prometheus.clientlibs``
^^^^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus linux alternatives for archives only.
This state will install prometheus client libraries on MacOS and GNU/Linux from archive.
``prometheus.package``
^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus package only.
``prometheus.package.repo``
^^^^^^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus package only.
This state will install prometheus component packages from GNU/Linux.
``prometheus.config``
^^^^^^^^^^^^^^^^^^^
This state will configure the prometheus service and has a dependency on ``prometheus.install``
via include list.
This state will apply prometheus service configuration (files).
``prometheus.service``
^^^^^^^^^^^^^^^^^^^^
This state will start the prometheus service and has a dependency on ``prometheus.config``
via include list.
This state will start prometheus component services.
``prometheus.clean``
^^^^^^^^^^^^^^^^^^
``prometheus.exporters``
^^^^^^^^^^^^^^^^^^^^^^
*Meta-state (This is a state that includes other states)*.
This state will apply prometheus exporters configuration.
this state will undo everything performed in the ``prometheus`` meta-state in reverse order, i.e.
stops the service,
removes the configuration file and
then uninstalls the package.
``prometheus.exporters.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove prometheus exporters configuration.
``prometheus.service.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will stop the prometheus service and disable it at boot time.
This state will stop prometheus component services.
``prometheus.config.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the configuration of the prometheus service and has a
dependency on ``prometheus.service.clean`` via include list.
This state will remove prometheus service configuration (files).
``prometheus.package.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the prometheus package and has a depency on
``prometheus.config.clean`` via include list.
This state will uninstall prometheus component packages from GNU/Linux.
``prometheus.package.archive.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``prometheus.clientlibs.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will uninstall the prometheus archive-extracted directory only.
This state will uninstall prometheus client libraries.
``prometheus.package.archive.alternatives.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``prometheus.archive.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will uninstall the prometheus linux alternatives for archives only.
This state will remove prometheus component archive (directories).
``prometheus.package.repo.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^
This state will uninstall the prometheus upstream package repository only.
Testing
-------
``prometheus.config.node_exporter.textfile_collectors``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Linux testing is done with ``kitchen-salt``.
Requirements
^^^^^^^^^^^^
* Ruby
* Docker
.. code-block:: bash
$ gem install bundler
$ bundle install
$ bin/kitchen test [platform]
Where ``[platform]`` is the platform name defined in ``kitchen.yml``,
e.g. ``debian-9-2019-2-py3``.
``bin/kitchen converge``
^^^^^^^^^^^^^^^^^^^^^^^^
Creates the docker instance and runs the ``prometheus`` main state, ready for testing.
``bin/kitchen verify``
^^^^^^^^^^^^^^^^^^^^^^
Runs the ``inspec`` tests on the actual instance.
``bin/kitchen destroy``
^^^^^^^^^^^^^^^^^^^^^^^
Removes the docker instance.
``bin/kitchen test``
^^^^^^^^^^^^^^^^^^^^
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.
``bin/kitchen login``
^^^^^^^^^^^^^^^^^^^^^
Gives you SSH access to the instance for manual testing.
This state will manage the node exporter's textfile collectors
according to Pillar ``prometheus:exporters:node_exporter:textfile_collectors``.

21
docs/_static/css/custom.css vendored Normal file
View File

@ -0,0 +1,21 @@
/*
Override styles for in-use Sphinx theme
*/
/* The next two `.wy`-based rules are specifically needed for the dealing with */
/* the `sphinx_rtd_theme` bug where long lines do not wrap in tables */
/* override table width restrictions */
.wy-table-responsive table th
, .wy-table-responsive table td
{
/* !important prevents the common CSS stylesheets from
overriding this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}
.wy-table-responsive
{
overflow: visible !important;
}

173
docs/conf.py Normal file
View File

@ -0,0 +1,173 @@
# -*- coding: utf-8 -*-
"""Configuration file for the Sphinx documentation builder.
This file does only contain a selection of the most common options. For a
full list see the documentation:
* http://www.sphinx-doc.org/en/stable/config
"""
from __future__ import division, print_function, unicode_literals
# from datetime import datetime
from recommonmark.parser import CommonMarkParser
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
__author__ = 'Imran Iqbal' # noqa: E221
__copyright__ = 'Copyright (C) 2019, MYII' # noqa: E221
__license__ = 'Apache-2.0' # noqa: E221
__version__ = 'latest' # noqa: E221
__maintainer__ = 'Imran Iqbal' # noqa: E221
# -- Project information -----------------------------------------------------
project = 'template-formula'
copyright = __copyright__.replace('Copyright (C) ', '') # noqa: A001
author = __author__
version = __version__
release = __version__
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['templates', '_templates', '.templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for the reStructuredText parser ---------------------------------
file_insertion_enabled = False
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'template-formula'
# -- Options for Markdown output ---------------------------------------------
source_parsers = {
'.md': CommonMarkParser,
}
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
'index',
'template-formula.tex',
u'template-formula Documentation',
u'',
'manual',
),
]
# -- Functions: `setup`, docstring preprocessing, etc. -----------------------
def setup(app):
"""Prepare the Sphinx application object.
Used for providing a custom CSS file for override styles.
Parameters
----------
app : object
The Sphinx application object.
Returns
-------
app : object
The Sphinx application object.
"""
app.add_stylesheet('css/custom.css')
return app

20
docs/index.rst Normal file
View File

@ -0,0 +1,20 @@
.. _index:
.. ``template-formula`` documentation master file.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to template-formula's documentation!
============================================
.. toctree::
:maxdepth: 2
:caption: Contents
:numbered:
:glob:
README <README>
CONTRIBUTING
TOFS_pattern
AUTHORS
CHANGELOG

View File

@ -36,6 +36,47 @@ platforms:
driver:
image: netmanagers/salt-master-py3:amazonlinux-2
## SALT `3000.2`
- name: debian-10-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:debian-10
- name: debian-9-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:debian-9
- name: ubuntu-1804-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:ubuntu-18.04
- name: centos-8-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:centos-8
- name: centos-7-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:centos-7
- name: fedora-31-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:fedora-31
- name: opensuse-leap-151-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-2-3000-2-py3
driver:
image: netmanagers/salt-3000.2-py3:amazonlinux-2
- name: ubuntu-1804-3000-2-py2
driver:
image: netmanagers/salt-3000.2-py2:ubuntu-18.04
- name: ubuntu-1604-3000-2-py2
driver:
image: netmanagers/salt-3000.2-py2:ubuntu-16.04
- name: arch-base-latest-3000-2-py2
driver:
image: netmanagers/salt-3000.2-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd
## SALT `2019.2`
- name: debian-10-2019-2-py3
driver:
@ -46,9 +87,15 @@ platforms:
- name: ubuntu-1804-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-18.04
- name: ubuntu-1604-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:ubuntu-16.04
- name: centos-8-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:centos-8
- name: centos-7-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:centos-7
- name: fedora-31-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:fedora-31
@ -60,78 +107,22 @@ platforms:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: centos-7-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:centos-7
- name: amazonlinux-2-2019-2-py3
driver:
image: netmanagers/salt-2019.2-py3:amazonlinux-2
- name: centos-6-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:centos-6
run_command: /sbin/init
- name: amazonlinux-1-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:amazonlinux-1
run_command: /sbin/init
- name: arch-base-latest-2019-2-py2
driver:
image: netmanagers/salt-2019.2-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd
## SALT `2018.3`
- name: fedora-30-2018-3-py3
driver:
image: netmanagers/salt-2018.3-py3:fedora-30
- name: debian-9-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:debian-9
- name: ubuntu-1604-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:ubuntu-16.04
- name: centos-7-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:centos-7
- name: opensuse-leap-151-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-1-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:amazonlinux-1
run_command: /sbin/init
- name: arch-base-latest-2018-3-py2
driver:
image: netmanagers/salt-2018.3-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd
## SALT `2017.7`
- name: debian-8-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:debian-8
- name: ubuntu-1604-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:ubuntu-16.04
- name: centos-6-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:centos-6
run_command: /sbin/init
- name: fedora-30-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:fedora-30
- name: opensuse-leap-151-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:opensuse-leap-15.1
run_command: /usr/lib/systemd/systemd
# Workaround to avoid intermittent failures on `opensuse-leap-15.1`:
# => SCP did not finish successfully (255): (Net::SCP::Error)
transport:
max_ssh_sessions: 1
- name: amazonlinux-1-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:amazonlinux-1
run_command: /sbin/init
- name: arch-base-latest-2017-7-py2
driver:
image: netmanagers/salt-2017.7-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd
provisioner:
name: salt_solo
log_level: debug
@ -156,6 +147,7 @@ suites:
state_top:
base:
'*':
# prometheus.clean
- prometheus
pillars:
top.sls:
@ -163,7 +155,24 @@ suites:
'*':
- prometheus
pillars_from_files:
prometheus.sls: pillar.example
prometheus.sls: test/salt/pillar/default.sls
verifier:
inspec_tests:
- path: test/integration/default
- name: repo
provisioner:
state_top:
base:
'*':
# prometheus.clean
- prometheus
pillars:
top.sls:
base:
'*':
- prometheus
pillars_from_files:
prometheus.sls: test/salt/pillar/repo.sls
verifier:
inspec_tests:
- path: test/integration/repo

View File

@ -3,54 +3,183 @@
---
prometheus:
wanted:
- prometheus
{%- if grains.os_family not in ('Debian',) %}
- alertmanager
{%- endif %}
- node_exporter
# no memcached_exporter in upstream repo - only archive
# memcached_exporter
clientlibs:
- golang
- haskell
- rust
component:
- prometheus
- alertmanager # not in debian repo, only archive
- node_exporter
# - memcached_exporter # not in upstream repo, only archive
use_upstream_archive: false
{%- if grains.os_family in ('CentOS',) %}
use_upstream_repo: false
{%- endif %}
pkg:
prometheus:
archive_version: '2.10.0'
archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
alertmanager:
archive_version: '0.17.0'
archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
service:
prometheus:
args:
web.listen-address: 0.0.0.0:9090
# pushgateway:
# args:
# web.listen-address: ":9091"
# web.telemetry-path: "/metrics"
exporters:
node_exporter:
args:
web.listen-address: ":9110"
# collector.textfile.directory: /var/tmp/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:
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.
# 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.
# 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
@ -60,123 +189,3 @@ prometheus:
- 'alt_config.yml.jinja'
prometheus-archive-install-managed-service:
- 'alt_systemd.ini.jinja'
# Pillar-based config
config:
prometheus:
# 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'
# ref 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 # The blackbox exporter's real hostname:port.
alertmanager:
# 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'
linux:
# 'Alternatives system' priority: zero disables (default)
# yamllint disable-line rule:braces
altpriority: {{ range(1, 9100000) | random }}
exporters:
node_exporter:
textfile_collectors:
ipmitool:
# You must enable individual collectors
enable: true
# pkg: ipmitool
smartmon:
enable: true
# pkg: smartmontools
# bash_pkg: bash
# smartctl: /usr/sbin/smartctl

View File

@ -13,6 +13,9 @@ sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
# Install `m2r`
sudo -H pip install m2r
# working directory
MYPWD=$( pwd )
# Copy and then convert the `.md` docs
cp ./*.md docs/
cd docs/ || exit
@ -27,4 +30,4 @@ sed -i -e '1,4s/-/=/g' CHANGELOG.rst
# cat CHANGELOG.rst
# Return back to the main directory
cd ..
cd "${MYPWD}" || exit

View File

@ -1,29 +1,26 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 %}
{%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
{%- if 'wanted' in p and p.wanted and 'component' in p.wanted and p.wanted.component %}
{%- for name in p.wanted %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
{%- for name in p.wanted.component %}
{%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
{%- for cmd in p.pkg.component[name]['commands'] %}
prometheus-archive-remove-{{ name }}-home-alternatives-remove:
prometheus-server-alternatives-clean-{{ name }}-{{ cmd }}:
alternatives.remove:
- name: prometheus-{{ name }}-home
- path: {{ p.dir.basedir }}/{{ bundle }}
- onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-home
- unless: {{ p.pkg.use_upstream_repo }}
- name: link-prometheus-{{ name }}-{{ cmd }}
- path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
- onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-{{ cmd }}
{% for b in p.pkg[name]['binaries'] %}
{%- endfor %}
{%- endif %}
{%- endfor %}
prometheus-archive-remove-{{ name }}-alternatives-remove-{{ b }}:
alternatives.remove:
- name: prometheus-{{ name }}-{{ b }}
- path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- onlyif: update-alternatives --get-selections |grep ^prometheus-{{ name }}-{{ b }}
{% endfor %}
{% endfor %}
{%- endif %}
{%- endif %}
{%- endif %}

View File

@ -1,81 +1,58 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_archive_install = tplroot ~ '.archive' %}
{%- if grains.kernel|lower in ('linux',) and p.linux.altpriority|int > 0 %}
{%- if grains.kernel|lower == 'linux' and p.linux.altpriority|int > 0 and grains.os_family != 'Arch' %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
include:
- {{ sls_archive_install }}
{%- for name in p.wanted %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
{%- if grains.os_family == 'Suse' %}
{%- if 'wanted' in p and p.wanted and 'component' in p.wanted and p.wanted.component %}
{%- for name in p.wanted.component %}
{%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
{%- set dir_symlink = p.dir.symlink ~ '/bin' %}
{%- if 'service' in p.pkg.component[name] %}
{%- set dir_symlink = p.dir.symlink ~ '/sbin' %}
{%- endif %}
{%- for cmd in p.pkg.component[name]['commands'] %}
prometheus-archive-alternatives-install-{{ name }}-home-cmd-run:
prometheus-server-alternatives-install-{{ name }}-{{ cmd }}:
cmd.run:
- name: |
update-alternatives --install {{ p.dir.basedir }}/{{ name }} \
prometheus-{{ name }}-home {{ p.dir.basedir }}/{{ bundle }} \
{{ p.linux.altpriority }}
- watch:
- archive: prometheus-archive-install-{{ name }}-archive-extracted
{%- else %}
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
alternatives.install:
- name: prometheus-{{ name }}-home
- link: {{ p.dir.basedir }}/{{ name }}
- path: {{ p.dir.basedir }}/{{ bundle }}
- priority: {{ p.linux.altpriority }}
- order: 10
- watch:
- archive: prometheus-archive-install-{{ name }}-archive-extracted
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-set:
alternatives.set:
- name: prometheus-{{ name }}-home
- path: {{ p.dir.basedir }}/{{ bundle }}
- name: update-alternatives --install {{ dir_symlink }}/{{ cmd }} link-prometheus-{{ name }}-{{ cmd }} {{ p.pkg.component[name]['path'] }}/{{ cmd }} {{ p.linux.altpriority }} # noqa 204
- unless:
- {{ grains.os_family not in ('Suse',) }}
- {{ p.pkg.use_upstream_repo }}
- require:
- alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
{%- endif %}
{% for b in p.pkg[name]['binaries'] %}
{%- if grains.os_family == 'Suse' %}
prometheus-archive-alternatives-install-{{ name }}-cmd-run-{{ b }}-alternative:
cmd.run:
- name: |
update-alternatives --install /usr/local/bin/{{ b }} \
prometheus-{{ name }}-{{ b }} {{ p.dir.basedir }}/{{ bundle }}/{{ b }} \
{{ p.linux.altpriority }}
- require:
- cmd: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run
{%- else %}
prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}:
- sls: {{ sls_archive_install }}
alternatives.install:
- name: prometheus-{{ name }}-{{ b }}
- link: /usr/local/bin/{{ b }}
- path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- name: link-prometheus-{{ name }}-{{ cmd }}
- link: {{ dir_symlink }}/{{ cmd }}
- path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
- priority: {{ p.linux.altpriority }}
- order: 10
- require:
- alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
- sls: {{ sls_archive_install }}
- unless:
- {{ grains.os_family in ('Suse',) }}
- {{ p.pkg.use_upstream_repo }}
prometheus-archive-alternatives-install-{{ name }}-alternatives-set-{{ b }}:
prometheus-server-alternatives-set-{{ name }}-{{ cmd }}:
alternatives.set:
- name: prometheus-{{ name }}-{{ b }}
- path: {{ p.dir.basedir }}/{{ bundle }}/{{ b }}
- name: link-prometheus-{{ name }}-{{ cmd }}
- path: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
- require:
- alternatives: prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}
- alternatives: prometheus-server-alternatives-install-{{ name }}-{{ cmd }}
- sls: {{ sls_archive_install }}
- unless:
- {{ grains.os_family in ('Suse',) }}
- {{ p.pkg.use_upstream_repo }}
{%- endfor %}
{%- endif %}
{% endfor %}
{% endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}

View File

@ -1,35 +1,43 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
{%- set sls_users_clean = tplroot ~ '.config.users.clean' %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_users_clean }}
- {{ sls_service_clean }}
- {{ sls_alternatives_clean }}
{%- for name in p.wanted %}
prometheus-archive-clean-prerequisites:
file.absent:
- name: {{ p.dir.var }}
prometheus-archive-clean-{{ name }}-file-absent:
{%- for name in p.wanted.component %}
prometheus-archive-clean-{{ name }}:
file.absent:
- name: {{ p.pkg.component[name]['path'] }}
{%- if p.linux.altpriority|int <= 0 or grains.os_family|lower in ('macos', 'arch') %}
{%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
{%- for cmd in p.pkg.component[name]['commands'] %}
prometheus-archive-clean-{{ name }}-file-symlink-{{ cmd }}:
file.absent:
- names:
- {{ p.dir.basedir }}/{{ name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) }}
prometheus-archive-clean-{{ name }}-user-absent:
user.absent:
- name: {{ name }}
group.absent:
- name: {{ name }}
- {{ p.dir.symlink }}/bin/{{ cmd }}
- {{ p.dir.symlink }}/sbin/{{ cmd }}
- {{ p.dir.var }}/{{ name }}
- {{ p.dir.service }}/{{ name }}.service
- require:
- user: prometheus-archive-clean-{{ name }}-user-absent
- sls: {{ sls_alternatives_clean }}
- sls: {{ sls_service_clean }}
- require_in:
- user: prometheus-archive-clean-{{ name }}-user-group
{%- endfor %}
prometheus-archive-clean-basedir-file-directory:
file.absent:
- name: {{ p.dir.basedir }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,11 +1,10 @@
#.-*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if prometheus.use_upstream_archive %}
{%- if p.pkg.use_upstream_archive %}
include:
- .install

View File

@ -1,70 +1,99 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_users_install = tplroot ~ '.config.users' %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
include:
- {{ sls_users_install }}
- {{ sls_config_users }}
prometheus-config-file-basedir-file-directory:
prometheus-archive-install-prerequisites:
pkg.installed:
- names: {{ p.pkg.deps|json }}
file.directory:
- name: {{ p.dir.basedir }}
- name: {{ p.dir.var }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
- require:
- sls: '{{ sls_users_install }}.*'
- sls: {{ sls_config_users }}
{%- for name in p.wanted %}
{%- if name in p.pkg %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
{%- for name in p.wanted.component %}
prometheus-archive-install-{{ name }}-archive-extracted:
archive.extracted:
- name: {{ p.dir.basedir }}
- source: {{ p.archive.uri }}/{{ name }}/releases/download/v{{ p.pkg[name]['archive_version']
+ '/' + bundle + '.' + p.archive.suffix }}
- source_hash: {{ p.pkg[name]['archive_hash'] }}
- user: {{ name }}
- group: {{ name }}
{{- format_kwargs(p.archive.kwargs) }}
prometheus-archive-install-{{ name }}:
file.directory:
- name: {{ p.pkg.component[name]['path'] }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- mode: '0755'
- makedirs: True
- require:
- file: prometheus-archive-install-prerequisites
- require_in:
- archive: prometheus-archive-install-{{ name }}
- recurse:
- user
- group
- mode
archive.extracted:
{{- format_kwargs(p.pkg.component[name]['archive']) }}
- trim_output: true
- enforce_toplevel: false
- options: --strip-components=1
- retry: {{ p.retry_option|json }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- require:
- file: prometheus-config-file-basedir-file-directory
- file: prometheus-archive-install-{{ name }}
{%- if name in p.service %}
{%- if p.linux.altpriority|int <= 0 or grains.os_family|lower in ('macos', 'arch') %}
{%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
{%- for cmd in p.pkg.component[name]['commands'] %}
prometheus-archive-install-{{ name }}-file-symlink-{{ cmd }}:
file.symlink:
{%- if 'service' in p.pkg.component[name] %}
- name: {{ p.dir.symlink }}/sbin/{{ cmd }}
{%- else %}
- name: {{ p.dir.symlink }}/bin/{{ cmd }}
{% endif %}
- target: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
- force: True
- require:
- archive: prometheus-archive-install-{{ name }}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] is mapping %}
prometheus-archive-install-{{ name }}-file-directory:
file.directory:
- name: {{ p.dir.var }}/{{ name }}
- user: {{ name }}
- group: {{ name }}
- mode: 755
- mode: '0755'
- makedirs: True
- require:
- archive: prometheus-archive-install-{{ name }}-archive-extracted
- file: prometheus-config-file-basedir-file-directory
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
{%- if grains.os_family not in ('MacOS', 'FreeBSD', 'Windows') %}
{%- if grains.kernel|lower == 'linux' and 'config_file' in p.pkg.component[name] %}
prometheus-archive-install-{{ name }}-managed-service:
file.managed:
- name: {{ p.dir.service }}/{{ name }}.service
- source: {{ files_switch(['systemd.ini.jinja'],
lookup='prometheus-archive-install-managed-service'
lookup='prometheus-archive-install-' ~ name ~ '-managed-service'
)
}}
- mode: 644
- user: root
- group: {{ p.rootgroup }}
- mode: '0644'
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- makedirs: True
- template: jinja
- context:
@ -73,17 +102,22 @@ prometheus-archive-install-{{ name }}-managed-service:
user: {{ name }}
group: {{ name }}
workdir: {{ p.dir.var }}/{{ name }}
start: {{ p.dir.basedir }}/{{ bundle }}/{{ name }} --config.file {{ p.dir.etc }}/{{ name }}.yml
stop: '' #not needed
stop: ''
{%- if name in ('node_exporter',) %}
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
{%- endif %}
- require:
- file: prometheus-archive-install-{{ name }}-file-directory
- file: prometheus-config-file-basedir-file-directory
- archive: prometheus-archive-install-{{ name }}
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
cmd.run:
- name: systemctl daemon-reload
- require:
- file: prometheus-archive-install-{{ name }}-managed-service
- archive: prometheus-archive-install-{{ name }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
#.-*- coding: utf-8 -*-
# vim: ft=sls
include:
- .service.clean
- .config.clean
- .exporters.clean
- .clientlibs.clean
- .archive.clean
- .package.clean

View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- for name in p.wanted.clientlibs %}
prometheus-clientlibs-clean-{{ name }}:
file.absent:
- name: {{ p.pkg.clientlibs[name]['path'] }}
{%- endfor %}

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
include:
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
{%- for name in p.wanted.clientlibs %}
prometheus-clientlibs-install-{{ name }}:
file.directory:
- name: {{ p.pkg.clientlibs[name]['path'] }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- mode: '0755'
- makedirs: True
- require_in:
- archive: prometheus-clientlibs-install-{{ name }}
- recurse:
- user
- group
- mode
archive.extracted:
{{- format_kwargs(p.pkg.clientlibs[name]['archive']) }}
- trim_output: true
- enforce_toplevel: false
- options: --strip-components=1
- retry: {{ p.retry_option|json }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
{%- endfor %}

View File

@ -1,71 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
{%- set args = {} %}
{%- if 'args' in prometheus.service[name] %}
{%- set args = prometheus.service[name]['args'] or {} %}
{%- endif %}
{%- if args and 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-data-dir:
file.absent:
- name: {{ args['storage.tsdb.path'] }}
- require:
- sls: '{{ sls_service_clean }}.*'
{%- if grains.os_family == 'FreeBSD' %}
prometheus-config-args-{{ name }}-{{ key }}:
sysrc.absent:
- name: {{ name }}_data_dir
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- endif %}
{%- endif %}
{%- if args and grains.os_family == 'FreeBSD' %}
prometheus-config-args-{{ name }}-all:
sysrc.absent:
- names:
- {{ name }}_args
- {{ name }}_listen_address
- {{ name }}_textfile_dir
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- elif grains.os_family != 'FreeBSD' %}
{%- set args_file = prometheus.pkg.get(name, {}).get('args_file', False) %}
{%- if not args_file %}
{%- set args_file = prometheus.dir.args | path_join(name) %}
{%- if not grains.os_family in ['Debian'] %}
{%- set args_file = "{}.sh".format(args_file) %}
{%- endif %}
{%- endif %}
prometheus-config-args-{{ name }}-file-absent:
file.absent:
- name: {{ args_file }}
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
- require_in:
- file: prometheus-config-file-args-file-absent
{%- endif %}
{%- endif %}
{%- endfor %}
prometheus-config-file-args-file-absent:
file.absent:
- name: {{ prometheus.dir.args }}

View File

@ -1,122 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import concat_args %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
{%- set sls_archive_install = tplroot ~ '.archive' %}
{%- set sls_package_install = tplroot ~ '.package' %}
include:
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
- {{ sls_config_users }}
{%- if prometheus.dir.args %}
prometheus-config-file-args-file-directory:
file.directory:
- name: {{ prometheus.dir.args }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
- require:
- sls: '{{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}.*'
{%- endif %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %}
{%- set args = {} %}
{%- if 'args' in prometheus.service[name] %}
{%- set args = prometheus.service[name]['args'] or {} %}
{%- endif %}
{%- if args and 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-data-dir:
file.directory:
- name: {{ args['storage.tsdb.path'] }}
- owner: {{ name }}
- group: {{ name }}
- makedirs: True
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- if prometheus.dir.args %}
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %}
{%- endif %}
{%- if args and grains.os_family == 'FreeBSD' %}
{%- if 'collector.textfile.directory' in args.keys() %}
prometheus-config-args-{{ name }}-collector-textfile-directory:
sysrc.managed:
- name: {{ name }}_textfile_dir
- value: {{ args.pop('collector.textfile.directory') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- if 'storage.tsdb.path' in args.keys() %}
prometheus-config-args-{{ name }}-storage-tsdb-path:
sysrc.managed:
- name: {{ name }}_data_dir
- value: {{ args.pop('storage.tsdb.path') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
{%- if name in ['node_exporter'] and 'web.listen-address' in args.keys() %}
prometheus-config-args-{{ name }}-web-listen-address:
sysrc.managed:
- name: {{ name }}_listen_address
- value: {{ args.pop('web.listen-address') }}
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- endif %}
prometheus-config-args-{{ name }}-config-file:
sysrc.managed:
- name: {{ name }}_config
- value: {{ prometheus.dir.etc }}/{{ name }}.yml
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
prometheus-config-args-{{ name }}-all:
sysrc.managed:
- name: {{ name }}_args
# service prometheus restart tended to hang on FreeBSD
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
- value: "{{ concat_args(args) }} >/dev/null 2>&1"
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- elif grains.os_family != 'FreeBSD' %}
{%- set args_file = prometheus.pkg.get(name, {}).get('args_file', False) %}
{%- if not args_file %}
{%- set args_file = prometheus.dir.args | path_join(name) %}
{%- if not grains.os_family in ['Debian'] %}
{%- set args_file = "{}.sh".format(args_file) %}
{%- endif %}
{%- endif %}
prometheus-config-args-{{ name }}-file-managed:
file.managed:
- name: {{ args_file }}
- contents: |
{{ prometheus.dir.args_setting }}="{{ concat_args(args) }}"
- watch_in:
- service: prometheus-service-running-{{ name }}-service-running
{%- if prometheus.dir.args %}
- require:
- file: prometheus-config-file-args-file-directory
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,8 +1,31 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- .file.clean
- .args.clean
- .users.clean
- .node_exporter.textfile_collectors.clean
- {{ sls_service_clean }}
{%- for name in p.wanted.component %}
prometheus-config-clean-{{ name }}:
- names:
- {{ p.dir.etc }}/{{ name }}.yml
- {{ p.pkg.component[name]['environ_file'] }}
{%- if grains.os_family|lower in ('freebsd',) %}
sysrc.absent:
- name: {{ name }}_environ
{%- endif %}
user.absent:
- name: {{ name }}
{%- if grains.os_family == 'MacOS' %}
- onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
{%- endif %}
group.absent:
- name: {{ name }}
- require:
- {{ sls_config_clean }}
{%- endfor %}

View File

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- from tplroot ~ "/files/macros.jinja" import concat_environ %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
include:
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
{%- for name in p.wanted.component %}
{%- if 'environ' in p.pkg.component[name] and p.pkg.component[name]['environ'] %}
{%- if 'environ_file' in p.pkg.component[name] and p.pkg.component[name]['environ_file'] %}
prometheus-config-install-{{ name }}-environ_file:
file.managed:
- name: {{ p.pkg.component[name]['environ_file'] }}
- source: {{ files_switch(['environ.sh.jinja'],
lookup='prometheus-config-install-' ~ name ~ '-environ_file'
)
}}
- mode: 640
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- makedirs: True
- template: jinja
- contents: |
command_args="{{ concat_environ(environ) }}"
- watch_in:
- service: prometheus-service-running-{{ name }}
- require:
- sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
{%- if grains.os_family == 'FreeBSD' %}
prometheus-config-environ-{{ name }}-all:
sysrc.managed:
- name: {{ name }}_environ
# service prometheus restart tends to hang on FreeBSD
# https://github.com/saltstack/salt/issues/44848#issuecomment-487016414
- value: "{{ concat_environ(p.pkg.component[name]['environ']) }} >/dev/null 2>&1"
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
include:
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
- {{ sls_config_users }}
prometheus-config-file-etc-file-directory:
file.directory:
- name: {{ p.dir.etc }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- mode: '0755'
- makedirs: True
- require:
- sls: {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
{%- for name in p.wanted.component %}
{%- if 'config' in p.pkg.component[name] and p.pkg.component[name]['config'] %}
prometheus-config-file-{{ name }}-file-managed:
file.managed:
- name: {{ p.dir.etc }}/{{ name }}.yml
- source: {{ files_switch(['config.yml.jinja'],
lookup='prometheus-config-file-' ~ name ~ '-file-managed'
)
}}
- mode: 644
- user: {{ name }}
- group: {{ name }}
- makedirs: True
- template: jinja
- context:
config: {{ p.pkg.component[name]['config']|json }}
- require:
- file: prometheus-config-file-etc-file-directory
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- endfor %}

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name in prometheus.wanted %}
prometheus-config-file-{{ name }}-file-absent:
file.absent:
- name: {{ prometheus.dir.etc }}/{{ name }}.yml
- require_in:
- file: prometheus-config-file-etc-file-absent
{%- endfor %}
prometheus-config-file-etc-file-absent:
file.absent:
- name: {{ prometheus.dir.etc }}
- require:
- sls: {{ sls_service_clean }}

View File

@ -1,5 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- .install

View File

@ -1,48 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
{%- set sls_archive_install = tplroot ~ '.archive' %}
{%- set sls_package_install = tplroot ~ '.package' %}
include:
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
- {{ sls_config_users }}
prometheus-config-file-etc-file-directory:
file.directory:
- name: {{ prometheus.dir.etc }}
- user: root
- group: {{ prometheus.rootgroup }}
- mode: 755
- makedirs: True
- require:
- sls: '{{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}.*'
{%- for name in prometheus.wanted %}
{%- if name in prometheus.config or name in prometheus.service %}
prometheus-config-file-{{ name }}-file-managed:
file.managed:
- name: {{ prometheus.dir.etc }}/{{ name }}.yml
- source: {{ files_switch(['config.yml.jinja'],
lookup='prometheus-config-file-file-managed'
)
}}
- mode: 644
- user: {{ name }}
- group: {{ name }}
- makedirs: True
- template: jinja
- context:
config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }}
- require:
- user: prometheus-config-user-install-{{ name }}-user-present
- file: prometheus-config-file-etc-file-directory
{%- endif %}
{%- endfor %}

View File

@ -1,14 +1,6 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
include:
- .users
- .args
- .file
{%- if 'node_exporter' in prometheus.wanted %}
- .node_exporter.textfile_collectors
{%- endif %}
- .environ

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
prometheus-node_exporter-textfile_collectors-dir:
file.absent:
- name: {{ prometheus.dir.textfile_collectors }}
prometheus-node_exporter-textfile-dir:
file.absent:
- name: {{ prometheus.service.node_exporter.args.get('collector.textfile.directory') }}
{%- for collector, config in prometheus.get('exporters', {}).get('node_exporter', {}).get('textfile_collectors', {}).items() %}
include:
- .{{ collector }}.clean
{%- endfor %}

View File

@ -1,50 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
prometheus-node_exporter-textfile_collectors-dir:
file.directory:
- name: {{ prometheus.dir.textfile_collectors }}
- mode: 755
- user: node_exporter
- group: node_exporter
- makedirs: True
prometheus-node_exporter-textfile-dir:
file.directory:
- name: {{ prometheus.service.node_exporter.args.get('collector.textfile.directory') }}
- mode: 755
- user: node_exporter
- group: node_exporter
- makedirs: True
{%- set states = [] %}
{%- for collector, config in prometheus.get('exporters', {}).get('node_exporter', {}).get('textfile_collectors', {}).items() %}
{%- if config.get('enable', False) %}
{%- if config.get('remove', False) %}
{%- set state = ".{}.clean".format(collector) %}
{%- else %}
{%- set state = ".{}".format(collector) %}
{%- endif %}
{%- do states.append(state) %}
{%- endif %}
{%- endfor %}
{%- if states|length > 0 %}
prometheus-node_exporter-textfile-dependencies:
pkg.installed:
- pkgs: {{ prometheus.exporters.node_exporter.textfile_collectors_dependencies }}
- require_in:
{%- for state in states %}
- sls: prometheus.config.node_exporter.textfile_collectors{{ state }}
{%- endfor %}
include:
{%- for state in states %}
- {{ state }}
{% endfor %}
{%- endif %}

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set config = prometheus.exporters.node_exporter.textfile_collectors.ipmitool %}
{%- set dir = prometheus.service.node_exporter.args.get('collector.textfile.directory') %}
{%- set script = prometheus.dir.textfile_collectors ~ '/ipmitool' %}
prometheus-exporters-node-textfile_collectors-ipmitool-pkg:
pkg.removed:
- name: {{ config.pkg }}
prometheus-exporters-node-textfile_collectors-ipmitool-script:
file.absent:
- name: {{ script }}
prometheus-exporters-node-textfile_collectors-ipmitool-output:
file.absent:
- name: {{ dir }}/ipmitool.prom
prometheus-exporters-node-textfile_collectors-ipmitool-cronjob:
cron.absent:
- identifier: prometheus-exporters-node-textfile_collectors-ipmitool-cronjob

View File

@ -1,32 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set config = prometheus.exporters.node_exporter.textfile_collectors.ipmitool %}
{%- set dir = prometheus.service.node_exporter.args.get('collector.textfile.directory') %}
{%- set script = prometheus.dir.textfile_collectors ~ '/ipmitool' %}
{%- set cmd_prefix = 'awk -f ' if grains.os_family in ['FreeBSD'] else '' %}
prometheus-exporters-node-textfile_collectors-ipmitool-pkg:
pkg.installed:
- name: {{ config.pkg }}
prometheus-exporters-node-textfile_collectors-ipmitool-script:
file.managed:
- name: {{ script }}
- source: salt://prometheus/config/node_exporter/textfile_collectors/files/ipmitool
- mode: 755
- require:
- file: prometheus-node_exporter-textfile_collectors-dir
prometheus-exporters-node-textfile_collectors-ipmitool-cronjob:
cron.present:
- identifier: prometheus-exporters-node-textfile_collectors-ipmitool-cronjob
- name: cd {{ dir }} && LANG=C ipmitool sensor | {{ cmd_prefix }}{{ script }} > .ipmitool.prom$$; mv .ipmitool.prom$$ ipmitool.prom
- minute: "{{ config.get('minute', '*') }}"
- comment: Prometheus' node_exporter's ipmitool textfile collector
- require:
- file: prometheus-exporters-node-textfile_collectors-ipmitool-script

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set config = prometheus.exporters.node_exporter.textfile_collectors.smartmon %}
{%- set dir = prometheus.service.node_exporter.args.get('collector.textfile.directory') %}
{%- set script = prometheus.dir.textfile_collectors ~ '/smartmon.sh' %}
prometheus-exporters-node-textfile_collectors-smartmon-pkg:
pkg.removed:
- name: {{ config.pkg }}
prometheus-exporters-node-textfile_collectors-smartmon-script:
file.absent:
- name: {{ script }}
prometheus-exporters-node-textfile_collectors-smartmon-output:
file.absent:
- name: {{ dir }}/smartmon.prom
prometheus-exporters-node-textfile_collectors-smartmon-cronjob:
cron.absent:
- identifier: prometheus-exporters-node-textfile_collectors-smartmon-cronjob

View File

@ -1,38 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set config = prometheus.exporters.node_exporter.textfile_collectors.smartmon %}
{%- set dir = prometheus.service.node_exporter.args.get('collector.textfile.directory') %}
{%- set script = prometheus.dir.textfile_collectors ~ '/smartmon.sh' %}
prometheus-exporters-node-textfile_collectors-smartmon-pkg:
pkg.installed:
- name: {{ config.pkg }}
prometheus-exporters-node-textfile_collectors-smartmon-pkg-bash:
pkg.installed:
- name: {{ config.bash_pkg }}
prometheus-exporters-node-textfile_collectors-smartmon-script:
file.managed:
- name: {{ script }}
- source: salt://prometheus/config/node_exporter/textfile_collectors/files/smartmon.sh.jinja
- template: jinja
- context:
smartctl: {{ config.smartctl }}
- mode: 755
- require:
- file: prometheus-node_exporter-textfile_collectors-dir
prometheus-exporters-node-textfile_collectors-smartmon-cronjob:
cron.present:
- identifier: prometheus-exporters-node-textfile_collectors-smartmon-cronjob
- name: cd {{ dir }} && LANG=C {{ script }} > .smartmon.prom$$ && mv .smartmon.prom$$ smartmon.prom
- minute: "{{ config.get('minute', '*') }}"
- comment: Prometheus' node_exporter's smartmon textfile collector
- require:
- file: prometheus-exporters-node-textfile_collectors-smartmon-script

View File

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- for name in prometheus.wanted %}
{%- for name in p.wanted.component %}
prometheus-config-user-install-{{ name }}-user-present:
group.present:
@ -18,8 +17,8 @@ prometheus-config-user-install-{{ name }}-user-present:
- createhome: false
- groups:
- {{ name }}
{%- if grains.os_family == 'MacOS' %}
{%- if grains.os_family == 'MacOS' %}
- unless: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- for name in prometheus.wanted %}
prometheus-config-user-clean-{{ name }}-user-absent:
user.absent:
- name: {{ name }}
{%- if grains.os_family == 'MacOS' %}
- onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
{%- endif %}
group.absent:
- name: {{ name }}
- require:
- user: prometheus-config-user-clean-{{ name }}-user-absent
{%- endfor %}

View File

@ -2,135 +2,286 @@
# vim: ft=yaml
---
prometheus:
rootgroup: root
# yamllint disable rule:braces
kernel: {{ grains.kernel | lower }}
arch: {{ grains.osarch }}
# yamllint enable rule:braces
use_upstream_repo: false
use_upstream_archive: false
wanted:
- prometheus
- alertmanager
- node_exporter
clientlibs:
- golang
component:
- prometheus
- alertmanager
- node_exporter
# memcached_exporter # only available as archive
firewall: false # disabled for travis ci
dir:
basedir: /opt/prometheus
default: /etc/default
archive: /opt/prometheus
etc: /etc/prometheus
var: /var/lib/prometheus
args: /etc/default
args_setting: ARGS
service: /usr/lib/systemd/system
textfile_collectors: /opt/prometheus/textfile_collectors
service:
prometheus:
args:
web.listen-address: 0.0.0.0:9090
alertmanager: {}
node_exporter:
args:
collector.textfile.directory: /var/tmp/node_exporter
config:
prometheus: {}
alertmanager: {}
node_exporter: {}
symlink: /usr/local
tmp: /tmp/prometheus
var: /var/lib/prometheus
pkg:
prometheus:
archive_version: '2.10.0'
archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
binaries:
- prometheus
- promtool
repo:
humanname: prometheus
name: prometheus
comments:
- installed by salt
enabled: 1
gpgcheck: 1
alertmanager:
archive_version: '0.17.0'
archive_hash: 7c8d2cfeb021c80881ae9904d959131091b8785b6fda9800f84ddef148fe0a4f
binaries:
- amtool
- alertmanager
blackbox_exporter:
archive_version: '0.14.0'
archive_hash: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117
binaries:
- blackbox_exporter
consul_exporter:
archive_version: '0.4.0'
archive_hash: ff77c03de67cf381f67480b5be6699901785a34145c518c3484ae3e5b8440d08
binaries:
- consul_exporter
graphite_exporter:
archive_version: '0.6.2'
archive_hash: 9b962bd06406ece4a865ad6947a6e652e48a92a0d77e496a0351c04e9c2c5e9e
binaries:
- graphite_exporter
haproxy_exporter:
archive_version: '0.10.0'
archive_hash: 08150728e281f813a8fcfff4b336f16dbfe4268a1c7510212c8cff2579b10468
binaries:
- haproxy_exporter
memcached_exporter:
archive_version: '0.5.0'
archive_hash: bb07f496ceb63dad9793ad4295205547a4bd20b90628476d64fa96c9a25a020f
binaries:
- memcached_exporter
mysqld_exporter:
archive_version: '0.11.0'
archive_hash: b53ad48ff14aa891eb6a959730ffc626db98160d140d9a66377394714c563acf
binaries:
- mysqld_exporter
node_exporter:
archive_version: '0.18.1'
archive_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
binaries:
- node_exporter
pushgateway:
archive_version: '0.8.0'
archive_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
binaries:
- pushgateway
statsd_exporter:
archive_version: '0.11.2'
archive_hash: 4632ad0c5552e271e84c376da3ffe3af8c265ec5c3035334b70e35756aca1906
binaries:
- statsd_exporter
archive:
uri: https://github.com/prometheus
suffix: tar.gz
kwargs:
trim_output: true
enforce_toplevel: true
archive_format: tar
retry:
attempts: 3
until: true
interval: 60
splay: 10
use_upstream_repo: false
use_upstream_package: true
use_upstream_archive: false
deps:
- gzip
- tar
repo:
humanname: prometheus
name: prometheus
comments:
- installed by salt
enabled: 1
gpgcheck: 1
component:
alertmanager:
version: v0.17.0
config_file: /etc/prometheus/alertmanager.yml
config: {}
environ_file: /etc/default/prometheus-alertmanager.sh
environ: {}
service:
name: alertmanager
args:
config.file: /etc/prometheus/alertmanager.yml
storage.path: /var/lib/alertmanager
firewall:
ports:
- tcp/9093
# tcp/9094
archive:
source_hash: 7c8d2cfeb021c80881ae9904d959131091b8785b6fda9800f84ddef148fe0a4f
commands:
- amtool
- alertmanager
blackbox_exporter:
version: v0.14.0
config_file: /etc/prometheus/blackbox_exporter.yml
config: {}
archive:
source_hash: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117
commands:
- blackbox_exporter
firewall:
ports:
- tcp/9110
consul_exporter:
version: v0.4.0
archive:
source_hash: ff77c03de67cf381f67480b5be6699901785a34145c518c3484ae3e5b8440d08
commands:
- consul_exporter
firewall:
ports:
- tcp/9107
graphite_exporter:
version: v0.6.2
archive:
source_hash: 9b962bd06406ece4a865ad6947a6e652e48a92a0d77e496a0351c04e9c2c5e9e
commands:
- graphite_exporter
firewall:
ports:
- tcp/9108
haproxy_exporter:
version: v0.10.0
archive:
source_hash: 08150728e281f813a8fcfff4b336f16dbfe4268a1c7510212c8cff2579b10468
commands:
- haproxy_exporter
firewall:
ports:
- tcp/9101
memcached_exporter:
version: v0.5.0
archive:
source_hash: bb07f496ceb63dad9793ad4295205547a4bd20b90628476d64fa96c9a25a020f
commands:
- memcached_exporter
firewall:
ports:
- tcp/9150
mysqld_exporter:
version: v0.11.0
archive:
source_hash: b53ad48ff14aa891eb6a959730ffc626db98160d140d9a66377394714c563acf
commands:
- mysqld_exporter
firewall:
ports:
- tcp/9207
node_exporter:
version: v0.18.1
environ_file: /etc/default/prometheus-node-exporter.sh
environ: {}
config_file: /etc/prometheus/node_exporter.yml
config: {}
service:
name: prometheus-node-exporter
args:
collector.textfile.directory: /var/tmp/node_exporter
archive:
source_hash: b2503fd932f85f4e5baf161268854bf5d22001869b84f00fd2d1f57b51b72424
commands:
- node_exporter
firewall:
ports:
- tcp/9100
prometheus:
name: prometheus
version: v2.10.0
config_file: /etc/prometheus/prometheus.yml
config: {}
environ_file: /etc/default/prometheus.sh
environ: {}
service:
name: prometheus
args:
config.file: /etc/prometheus/prometheus.yml
storage.tsdb.path: /var/lib/prometheus/data
commands:
- prometheus
- promtool
archive:
source_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7
firewall:
ports:
- tcp/9090
pushgateway:
version: v0.8.0
environ_file: /etc/default/prometheus-pushgateway.sh
environ: {}
config_file: /etc/prometheus/pushgateway.yml
config: {}
service: {}
archive:
source_hash: 6949866ba9ad0cb88d3faffd4281f17df79281398b4dbd0ec3aab300071681ca
commands:
- pushgateway
firewall:
ports:
- tcp/9091
statsd_exporter:
version: v0.11.2
archive:
source_hash: 4632ad0c5552e271e84c376da3ffe3af8c265ec5c3035334b70e35756aca1906
commands:
- statsd_exporter
firewall:
ports:
- tcp/9102
clientlibs:
# https://prometheus.io/docs/instrumenting/clientlibs
# no bash & perl client tarballs are available
golang:
version: v1.6.0
archive:
uri: https://github.com/prometheus/client_golang/archive
skip_verify: true
java:
version: vparent-0.9.0
archive:
uri: https://github.com/prometheus/client_java/archive
skip_verify: true
python:
version: v0.7.1
archive:
uri: https://github.com/prometheus/client_python/archive
skip_verify: true
ruby:
version: v2.0.0
archive:
uri: https://github.com/prometheus/client_ruby/archive
skip_verify: true
c:
version: v0.1.1
archive:
uri: https://github.com/digitalocean/prometheus-client-c/archive
skip_verify: true
cpp:
version: v0.9.0
archive:
uri: https://github.com/jupp0r/prometheus-cpp/archive
skip_verify: true
clisp:
version: v0.4.1
archive:
uri: https://github.com/deadtrickster/prometheus.cl/archive
skip_verify: true
dart:
version: v0.4.0+4
archive:
uri: https://github.com/tentaclelabs/prometheus_client/archive
skip_verify: true
elixir:
version: v2.0.0
archive:
uri: https://github.com/deadtrickster/prometheus.ex/archive
skip_verify: true
erlang:
version: v4.4.0
archive:
uri: https://github.com/deadtrickster/prometheus.erl/archive
skip_verify: true
haskell:
version: prometheus-proc-0.1.2.0
archive:
uri: https://github.com/fimad/prometheus-haskell/archive
skip_verify: true
nginx-lua:
version: v0.20200420
archive:
uri: https://github.com/knyar/nginx-lua-prometheus/archive
skip_verify: true
tarantool-lua:
version: v1.0.4
archive:
uri: https://github.com/tarantool/prometheus/archive
skip_verify: true
net:
version: v3.5.0
archive:
uri: https://github.com/prometheus-net/prometheus-net/archive
skip_verify: true
node:
version: v12.0.0
archive:
uri: https://github.com/siimon/prom-client/archive
skip_verify: true
php:
version: v1.0.2
archive:
uri: https://github.com/endclothing/prometheus_client_php/archive
skip_verify: true
r:
version: v1.0.1
archive:
uri: https://github.com/cfmack/pRometheus/archive
skip_verify: true
rust:
version: v0.8.0
archive:
uri: https://github.com/tikv/rust-prometheus/archive
skip_verify: true
# Just here for testing
added_in_defaults: defaults_value
winner: defaults
identity:
rootuser: root
rootgroup: root
retry_option:
# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
attempts: 3
until: true
interval: 60
splay: 10
linux:
altpriority: 0 ## 'Alternatives system' priority: zero disables (default)
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
altpriority: 0
kernel: linux

View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if 'exporters' in p and p.exporters and 'node_exporter' in p.exporters %}
include:
- .node_exporter.clean
{%- endif %}

View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if 'node_exporter' in p.wanted.component and 'exporters' in p and 'node_exporter' in p.exporters %}
include:
- .node_exporter
{%- endif %}

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if 'textfile_collectors' in p.exporters.node_exporter %}
include:
- .textfile_collectors.clean
{%- endif %}

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if 'textfile_collectors' in p.exporters.node_exporter %}
include:
- .textfile_collectors
{%- endif %}

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set name = 'node_exporter' %}
{%- if name in p.wanted.component and 'service' in p.pkg.component[name] %}
{%- if 'collector' in p.pkg.component[name]['service']['args'] %}
prometheus-exporters-{{ name }}-collector-textfile-dir-absent:
file.absent:
- names:
- {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
- {{ p.dir.textfile_collectors }}
{%- endif %}
include:
{%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %}
- .{{ k }}.clean
{%- endfor %}
{%- endif %}

View File

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
include:
- {{ sls_config_users }}
{%- set states = [] %}
{%- set name = 'node_exporter' %}
{%- if name in p.wanted.component and 'service' in p.pkg.component[name] %}
{%- if 'collector' in p.pkg.component[name]['service']['args'] %}
prometheus-exporters-{{ name }}-collector-textfile-dir:
file.directory:
- name: {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
- mode: 755
- user: {{ name }}
- group: {{ name }}
- makedirs: True
- requre:
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
{%- endif %}
{%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %}
{%- if v.get('enable', False) %}
{%- if v.get('remove', False) %}
{%- set state = ".{}.clean".format(k) %}
{%- else %}
{%- set state = ".{}".format(k) %}
{%- endif %}
{%- do states.append(state) %}
{%- endif %}
{%- endfor %}
{%- if states|length > 0 and p.exporters[name]['textfile_collectors_dependencies'] %}
prometheus-exporters-{{ name }}-textfile-dependencies:
pkg.installed:
- pkgs: {{ p.exporters[name]['textfile_collectors_dependencies'] }}
- require_in:
{%- for state in states %}
- sls: p.pkg.component[name]['config'][textfile_collectors{{ state }}
{%- endfor %}
include:
{%- for state in states %}
- {{ state }}
{% endfor %}
{%- endif %}
{%- endif %}

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set name = 'node_exporter' %}
prometheus-exporters-clean-{{ name }}-textfile_collectors-ipmitool:
pkg.removed:
- name: {{ p.exporters[name]['textfile_collectors']['ipmitool']['pkg'] }}
file.absent:
- names:
- {{ p.dir.archive ~ '/textfile_collectors/ipmitool' }}
- {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}/ipmitool.prom
cron.absent:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-ipmitool-cronjob

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set name = 'node_exporter' %}
{%- set config = p.exporters[name]['textfile_collectors']['ipmitool'] %}
{%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
{%- set script = p.dir.archive ~ '/textfile_collectors/ipmitool' %}
{%- set cmd_prefix = 'awk -f ' if grains.os_family in ['FreeBSD'] else '' %}
prometheus-exporters-install-{{ name }}-textfile_collectors-ipmitool:
pkg.installed:
- name: {{ config.pkg }}
file.managed:
- name: {{ script }}
- source: salt://prometheus/exporters-install/{{ name }}/textfile_collectors/files/ipmitool
- mode: 755
cron.present:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-ipmitool-cronjob
- name: cd {{ dir }} && LANG=C ipmitool sensor | {{ cmd_prefix }}{{ script }} > .ipmitool.prom$$; mv .ipmitool.prom$$ ipmitool.prom
- minute: "{{ config.get('minute', '*') }}"
- comment: Prometheus' {{ name }}'s ipmitool textfile collector
- require:
- file: prometheus-exporters-install-{{ name }}-textfile_collectors-ipmitool

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set name = 'node_exporter' %}
prometheus-exporters-clean-{{ name }}-textfile_collectors-smartmon:
pkg.removed:
- name: {{ p.exporters[name]['textfile_collectors']['smartmon']['pkg'] }}
file.absent:
- names:
- {{ p.dir.archive ~ '/textfile_collectors/smartmon.sh' }}
- {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}/smartmon.prom
cron.absent:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-smartmon-cronjob

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set name = 'node_exporter' %}
{%- set config = p.exporters[name]['textfile_collectors']['smartmon'] %}
{%- set dir = {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
{%- set script = p.dir.archive ~ '/textfile_collectors/smartmon.sh' %}
prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon:
pkg.installed:
- names:
- {{ config.pkg }}
- {{ config.bash_pkg }}
file.managed:
- name: {{ script }}
- source: salt://prometheus/exporters/{{ name }}/textfile_collectors/files/smartmon.sh.jinja
- template: jinja
- context:
smartctl: {{ config.smartctl }}
- mode: 755
cron.present:
- identifier: prometheus-exporters-{{ name }}-textfile_collectors-smartmon-cronjob
- name: cd {{ dir }} && LANG=C {{ script }} > .smartmon.prom$$ && mv .smartmon.prom$$ smartmon.prom
- minute: "{{ config.get('minute', '*') }}"
- comment: Prometheus' {{ name }}'s smartmon textfile collector
- require:
- file: prometheus-exporters-install-{{ name }}-textfile_collectors-smartmon

View File

@ -3,8 +3,4 @@
# Your changes may be overwritten.
########################################################################
{%- if defaults %}
{%- for item in defaults %}
{{ item }}
{%- endfor %}
{%- endif %}
{{ config|yaml(False) }}

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
#
# Collection of common macros
{%- macro format_kwargs(kwarg) -%}
{%- filter indent(4) %}
{%- for k, v in kwarg|dictsort() %}
- {{ k }}: {{ v }}
{%- endfor %}
{%- endfilter %}
{%- endmacro %}
{%- macro concat_args(args) %}
{%- set args = args|dictsort %}
{%- if args|length > 0 %}
{%- for k,v in args -%}
{%- if not k or not v %}{% continue %}{% endif -%}
{%- if v == True -%}
--{{ k }}
{%- elif v == False -%}
--no-{{ k }}
{%- else -%}
--{{ k }}={{ v }}
{%- endif -%}
{%- if not loop.last %} {% endif -%}
{%- endfor -%}
{%- endif -%}
{%- endmacro %}

View File

@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
#.-*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
include:
- {{ '.archive' if prometheus.use_upstream_archive else '.package' }}
- {{ '.archive' if p.pkg.use_upstream_archive else '.package' }}
- .config
- .service
- .exporters
- .clientlibs

View File

@ -1,14 +0,0 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
#
# Collection of common macros
{%- macro format_kwargs(kwarg) -%}
{%- filter indent(4) %}
{%- for k, v in kwarg|dictsort() %}
- {{ k }}: {{ v }}
{%- endfor %}
{%- endfilter %}
{%- endmacro %}

View File

@ -2,7 +2,7 @@
lookup=None,
default_files_switch=['id', 'os_family'],
indent_width=6,
use_subpath=False) %}
v1_path_prefix='') %}
{#-
Returns a valid value for the "source" parameter of a "file.managed"
state function. This makes easier the usage of the Template Override and
@ -10,15 +10,15 @@
Params:
* source_files: ordered list of files to look for
* lookup: key under '<tplroot>:tofs:source_files' to prepend to the
* lookup: key under '<tplroot>:tofs:source_files' to override
list of source files
* default_files_switch: if there's no config (e.g. pillar)
'<tplroot>:tofs:files_switch' this is the ordered list of grains to
use as selector switch of the directories under
"<path_prefix>/files"
* indent_width: indentation of the result value to conform to YAML
* use_subpath: defaults to `False` but if set, lookup the source file
recursively from the current state directory up to `tplroot`
* indent_witdh: indentation of the result value to conform to YAML
* v1_path_prefix: (deprecated) only used for injecting a path prefix into
the source, to support older TOFS configs
Example (based on a `tplroot` of `xxx`):
@ -55,24 +55,20 @@
tplroot ~ ':tofs:files_switch',
default_files_switch
) %}
{#- Lookup source_files (v2), files (v1), or fallback to an empty list #}
{#- Lookup source_files (v2), files (v1), or fallback to source_files parameter #}
{%- set src_files = salt['config.get'](
tplroot ~ ':tofs:source_files:' ~ lookup,
salt['config.get'](tplroot ~ ':tofs:files:' ~ lookup, [])
salt['config.get'](
tplroot ~ ':tofs:files:' ~ lookup,
source_files
)
) %}
{#- Append the default source_files #}
{%- set src_files = src_files + source_files %}
{#- Only add to [''] when supporting older TOFS implementations #}
{%- set path_prefix_exts = [''] %}
{%- if use_subpath and tplroot != tpldir %}
{#- Walk directory tree to find {{ files_dir }} #}
{%- set subpath_parts = tpldir.lstrip(tplroot).lstrip('/').split('/') %}
{%- for path in subpath_parts %}
{%- set subpath = subpath_parts[0:loop.index] | join('/') %}
{%- do path_prefix_exts.append('/' ~ subpath) %}
{%- endfor %}
{%- if v1_path_prefix != '' %}
{%- do path_prefix_exts.append(v1_path_prefix) %}
{%- endif %}
{%- for path_prefix_ext in path_prefix_exts|reverse %}
{%- for path_prefix_ext in path_prefix_exts %}
{%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
{#- For older TOFS implementation, use `files_switch` from the config #}
{#- Use the default, new method otherwise #}
@ -82,30 +78,23 @@
) %}
{#- Append an empty value to evaluate as `default` in the loop below #}
{%- if '' not in fsl %}
{%- set fsl = fsl + [''] %}
{%- do fsl.append('') %}
{%- endif %}
{%- for fs in fsl %}
{%- for src_file in src_files %}
{%- if fs %}
{%- set fs_dirs = salt['config.get'](fs, fs) %}
{%- set fs_dir = salt['config.get'](fs, fs) %}
{%- else %}
{%- set fs_dirs = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
{%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
{%- endif %}
{#- Force the `config.get` lookup result as a list where necessary #}
{#- since we need to also handle grains that are lists #}
{%- if fs_dirs is string %}
{%- set fs_dirs = [fs_dirs] %}
{%- endif %}
{%- for fs_dir in fs_dirs %}
{%- set url = [
'- salt:/',
path_prefix_inc_ext.strip('/'),
files_dir.strip('/'),
fs_dir.strip('/'),
src_file.strip('/'),
] | select | join('/') %}
{%- set url = [
'- salt:/',
path_prefix_inc_ext.strip('/'),
files_dir.strip('/'),
fs_dir.strip('/'),
src_file.strip('/'),
] | select | join('/') %}
{{ url | indent(indent_width, true) }}
{%- endfor %}
{%- endfor %}
{%- endfor %}
{%- endfor %}

View File

@ -1,48 +1,53 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{#- Start imports as #}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- set _config = salt['config.get'](tplroot, default={}) %}
{%- set defaults = salt['grains.filter_by'](default_settings,
default='prometheus',
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['pillar.get']('prometheus:lookup', default={})
{%- set defaults = salt['grains.filter_by'](
default_settings,
default=tplroot,
merge=salt['grains.filter_by']( osfamilymap, grain='os_family',
merge=salt['grains.filter_by']( osarchmap, grain='osarch',
merge=salt['grains.filter_by']( _config, default='lookup'
)
)
)
)
) %}
%}
{%- set p = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}
{#- Merge the prometheus pillar #}
{%- set prometheus = salt['pillar.get']('prometheus', default=defaults, merge=True) %}
{#- Post-processing for specific non-YAML customisations #}
{%- if grains.os == 'MacOS' %}
{%- set macos_user = salt['cmd.run']("stat -f '%Su' /dev/console") %}
{%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- do prometheus.update({'rootuser': macos_user}) %}
{%- do prometheus.update({'rootgroup': macos_group}) %}
{# ## components ## #}
{%- if 'component' in p.pkg and p.pkg.component is mapping %}
{%- for name,v in p.pkg.component.items() %}
{%- set url = None %}
{%- set dir = name %}
{%- if 'version' in v and v.version and 'archive' in v and v.archive and 'uri' in p.pkg %}
{%- set uri = '%s/%s/releases/download/%s/%s'|format(p.pkg.uri, name, v.version, name) %}
{%- set url = '%s-%s.%s-%s.tar.gz'|format(uri, v.version|replace('v',''), p.kernel, p.arch) %}
{%- set dir = '%s-%s'|format(name, v.version) %}
{%- endif %}
{%- do p.pkg.component[name].update({'path': p.dir.archive ~ '/' + dir }) %}
{%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %}
{%- endfor %}
{%- endif %}
{#- Contactenate arguments #}
{%- macro concat_args(args) %}
{%- set args = args|dictsort %}
{%- if args|length > 0 %}
{%- for k,v in args -%}
{%- if not k or not v %}{% continue %}{% endif -%}
{%- if v == True -%}
--{{ k }}
{%- elif v == False -%}
--no-{{ k }}
{%- else -%}
--{{ k }}={{ v }}
{%- endif -%}
{%- if not loop.last %} {% endif -%}
{%- endfor -%}
{%- endif -%}
{%- endmacro %}
{# ## clientlibs ## #}
{%- if 'clientlibs' in p.pkg and p.pkg.clientlibs is mapping %}
{%- for name,v in p.pkg.clientlibs.items() %}
{%- set url = None %}
{%- set dir = name %}
{%- if 'version' in v and v.version and 'archive' in v and v.archive and 'uri' in v.archive %}
{%- set url = v.archive.uri ~ '/' ~ v.version ~ '.tar.gz' %}
{%- set dir = name ~ '-' ~ v.version %}
{%- endif %}
{%- do p.pkg.clientlibs[name].update({'path': p.dir.archive ~ '/' + dir }) %}
{%- do p.pkg.clientlibs[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %}
{%- endfor %}
{%- endif %}
{%- set prometheus = p %}

View File

@ -10,14 +10,29 @@
# you will need to provide at least an empty dict in this file, e.g.
# osfamilymap: {}
---
{%- if grains.os == 'MacOS' %}
{%- set macos_rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %}
{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- endif %}
Arch: {}
Alpine: {}
Debian:
pkg:
node_exporter:
name: prometheus-node-exporter
args_file: /etc/default/prometheus-node-exporter
service:
node_exporter:
name: prometheus-node-exporter
deps:
- cron
use_upstream_repo: true
use_upstream_package: false
use_upstream_archive: false
repo:
humanname: prometheus repository
key_url: 'https://s3-eu-west-1.amazonaws.com/deb.robustperception.io/41EFC99D.gpg'
file: /etc/apt/sources.list.d/prometheus.list
component:
node_exporter:
args_file: /etc/default/prometheus-node-exporter
exporters:
node_exporter:
textfile_collectors_dependencies:
@ -25,75 +40,74 @@ Debian:
RedHat:
pkg:
prometheus:
repo:
# yamllint disable rule:line-length
baseurl: 'https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch'
gpgkey: 'https://packagecloud.io/prometheus-rpm/release/gpgkey gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
# yamllint enable rule:line-length
metadata_expire: 300
use_upstream_repo: false # not working on cent8
use_upstream_archive: false
component:
prometheus:
name: prometheus2
repo:
# https://akai-tsuki.hatenablog.com/entry/2017/12/03/000000
# yamllint disable rule:line-length
baseurl: 'https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch'
gpgkey: 'https://packagecloud.io/prometheus-rpm/release/gpgkey gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
# yamllint enable rule:line-length
sslverify: 1
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
metadata_expire: 300
Suse: {}
Gentoo:
dir:
args: false
args_setting: command_args
textfile_collectors: /var/lib/node_exporter/
pkg:
prometheus:
name: app-metrics/prometheus
args_file: /etc/conf.d/prometheus
node_exporter:
name: app-metrics/node_exporter
args_file: /etc/conf.d/node_exporter
alertmanager:
name: app-metrics/alertmanager
args_file: /etc/conf.d/alertmanager
service:
node_exporter:
args:
collector.textfile.directory: /var/lib/node_exporter
alertmanager:
args:
config.file: /etc/prometheus/alertmanager.yml
storage.path: /var/lib/alertmanager
prometheus:
args:
config.file: /etc/prometheus/prometheus.yml
storage.tsdb.path: /var/lib/prometheus/data
Arch: {}
Alpine: {}
component:
alertmanager:
name: app-metrics/alertmanager
args_file: /etc/conf.d/alertmanager
node_exporter:
name: app-metrics/node_exporter
args_file: /etc/conf.d/node_exporter
prometheus:
name: app-metrics/prometheus
args_file: /etc/conf.d/prometheus
FreeBSD:
rootgroup: wheel
identity:
rootgroup: wheel
dir:
args: false
etc: /usr/local/etc/prometheus
pkg:
prometheus:
archive_hash: 94a63f14baeadab2f17b5ae0bbeda6688e6d06f964ef4e32c2954a0ecf3996a1
alertmanager:
archive_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
blackbox_exporter:
archive_hash: 2b92752decf2cf1883ce4f72301e4f911dab79efbd87db4df23dc9771e53e4af
consul_exporter:
archive_hash: 62e16c2f1acb9bf9411126478caccb5962da203cfb58d8c97f54b9c0add5171c
graphite_exporter:
archive_hash: ff424b923733d8247314353ba4d13a1c4b06450c35f005bfd6c3b6ff60b047fd
haproxy_exporter:
archive_hash: f32d158f9e3314828dc155a30a1f4c858876e1ea8ff543a4000afcbc7e923505
memcached_exporter:
archive_hash: 8fd53b9aede6b78e0530b159ccd0a437cf2f100da1ddc586681f389d804f5f19
mysqld_exporter:
archive_hash: 9bcbbd8b3568818fd4c95d255c6f93c357ea25aed3364d7428f4ff9c89cd489a
node_exporter: {}
pushgateway:
archive_hash: ebcd21dc25e439eed64559e89cd7da9a94073d5ff321a8a3a4214ac2ebe04e34
statsd_exporter:
archive_hash: f345dff6311501f09bb5b6ba1128e925d504c6325ee97ad91a975f2be0d44da9
component:
prometheus:
archive:
source_hash: 94a63f14baeadab2f17b5ae0bbeda6688e6d06f964ef4e32c2954a0ecf3996a1
alertmanager:
archive:
source_hash: ec171b13976baceace193461f8a1e61021ab9657df5ba45157cd0095aee7d569
blackbox_exporter:
archive:
source_hash: 2b92752decf2cf1883ce4f72301e4f911dab79efbd87db4df23dc9771e53e4af
consul_exporter:
archive:
source_hash: 62e16c2f1acb9bf9411126478caccb5962da203cfb58d8c97f54b9c0add5171c
graphite_exporter:
archive:
source_hash: ff424b923733d8247314353ba4d13a1c4b06450c35f005bfd6c3b6ff60b047fd
haproxy_exporter:
archive:
source_hash: f32d158f9e3314828dc155a30a1f4c858876e1ea8ff543a4000afcbc7e923505
memcached_exporter:
archive:
source_hash: 8fd53b9aede6b78e0530b159ccd0a437cf2f100da1ddc586681f389d804f5f19
mysqld_exporter:
archive:
source_hash: 9bcbbd8b3568818fd4c95d255c6f93c357ea25aed3364d7428f4ff9c89cd489a
node_exporter: {}
pushgateway:
archive:
source_hash: ebcd21dc25e439eed64559e89cd7da9a94073d5ff321a8a3a4214ac2ebe04e34
statsd_exporter:
archive:
source_hash: f345dff6311501f09bb5b6ba1128e925d504c6325ee97ad91a975f2be0d44da9
exporters:
node_exporter:
textfile_collectors:
@ -101,29 +115,41 @@ FreeBSD:
smartctl: /usr/local/sbin/smartctl
OpenBSD:
rootgroup: wheel
identity:
rootgroup: wheel
kernel: openbsd
pkg:
prometheus:
archive_hash: c3c69919b359f00a84ef12f7ed6a956111790d64a71bd94990572baaf63377ce
alertmanager:
archive_hash: 88ce1b3f11bb28f24b98235994277b2c31aa03b2b2609e0058c04efa0cc5596f
blackbox_exporter:
archive_hash: 0dee97d1204bac925bde919958ae890730d87386a816ed0b248c8038ee43794d
consul_exporter:
archive_hash: b53ee2bd0e670907eac894387e286b0dd11eb3149fcd4e19ed586006d3de741a
graphite_exporter:
archive_hash: 98cbd7176f1c61023892de64ad26edc3cd7895037e3cc282c4edec53dded7156
haproxy_exporter:
archive_hash: bc2b222f6a08232ef643cd6dcda3264f3bd7388a5bee25365cef137c7dea17e8
memcached_exporter:
archive_hash: 21db1bffc561d47b4490ccb2cde721244d00e95f504cdcfee618bc4bb877e731
mysqld_exporter:
archive_hash: b37d6fe68e2c884540ea41c5efcfb16d0bc5da517fe3ba713144504df1ba635d
pushgateway:
archive_hash: 0bce168e4b19234df9e954393a2102c91e4d62336b2721ed882f2003a4445d51
statsd_exporter:
archive_hash: c89acb365b75af03ce612873d8b20226e3882c0177752ea0ce17a9f5e41eb5b4
component:
prometheus:
archive:
source_hash: c3c69919b359f00a84ef12f7ed6a956111790d64a71bd94990572baaf63377ce
alertmanager:
archive:
source_hash: 88ce1b3f11bb28f24b98235994277b2c31aa03b2b2609e0058c04efa0cc5596f
blackbox_exporter:
archive:
source_hash: 0dee97d1204bac925bde919958ae890730d87386a816ed0b248c8038ee43794d
consul_exporter:
archive:
source_hash: b53ee2bd0e670907eac894387e286b0dd11eb3149fcd4e19ed586006d3de741a
graphite_exporter:
archive:
source_hash: 98cbd7176f1c61023892de64ad26edc3cd7895037e3cc282c4edec53dded7156
haproxy_exporter:
archive:
source_hash: bc2b222f6a08232ef643cd6dcda3264f3bd7388a5bee25365cef137c7dea17e8
memcached_exporter:
archive:
source_hash: 21db1bffc561d47b4490ccb2cde721244d00e95f504cdcfee618bc4bb877e731
mysqld_exporter:
archive:
source_hash: b37d6fe68e2c884540ea41c5efcfb16d0bc5da517fe3ba713144504df1ba635d
pushgateway:
archive:
source_hash: 0bce168e4b19234df9e954393a2102c91e4d62336b2721ed882f2003a4445d51
statsd_exporter:
archive:
source_hash: c89acb365b75af03ce612873d8b20226e3882c0177752ea0ce17a9f5e41eb5b4
Solaris: {}
@ -132,49 +158,77 @@ Windows:
dir:
opt: C:\\Program Files
pkg:
prometheus:
archive_hash: eb138082a4d5e4d5b1e3ca838fa508f053474d46bca76e87ab0834f0d8b110db
alertmanager:
archive_hash: 512dbed02a3cc7e3f06d737f56179e458c462762b3427063b89c62a54d9645c6
blackbox_exporter:
archive_hash: 21ea148870631310002cbd48be54ca45e8d300da5a902b0aec052f1a64316d93
consul_exporter:
archive_hash: 54579bc5dfa6a238e310a1874b0a362027661dfa1754535e74610dc8ef6163b1
graphite_exporter:
archive_hash: f83fad71bad99ccac145d65f82bf9d17fa37168a5dcce6415c6350e79a84e638
haproxy_exporter:
archive_hash: 044118feb98b74eb921e27bd4b511732b553896c672c19bdd3418445dc030794
memcached_exporter:
archive_hash: 9e83c00c9d249c942f65b6a48112e6bd6e28a3d15b8a1d35e935621657b3d837
mysqld_exporter:
archive_hash: 38605ae648f8def07a0f412d81a30a6c48c0d20a6981468d25b91c8aa529e599
pushgateway:
archive_hash: 506b555e7a13cabf3d85ec0dbe1bc6bc3a2444c0cc468baa8d31e7fc2fe18dd1
statsd_exporter:
archive_hash: 9362b7482e74792f111c4bb1a372b18a88f6354c78f24713bacfbcb050883556
component:
prometheus:
archive:
source_hash: eb138082a4d5e4d5b1e3ca838fa508f053474d46bca76e87ab0834f0d8b110db
alertmanager:
archive:
source_hash: 512dbed02a3cc7e3f06d737f56179e458c462762b3427063b89c62a54d9645c6
blackbox_exporter:
archive:
source_hash: 21ea148870631310002cbd48be54ca45e8d300da5a902b0aec052f1a64316d93
consul_exporter:
archive:
source_hash: 54579bc5dfa6a238e310a1874b0a362027661dfa1754535e74610dc8ef6163b1
graphite_exporter:
archive:
source_hash: f83fad71bad99ccac145d65f82bf9d17fa37168a5dcce6415c6350e79a84e638
haproxy_exporter:
archive:
source_hash: 044118feb98b74eb921e27bd4b511732b553896c672c19bdd3418445dc030794
memcached_exporter:
archive:
source_hash: 9e83c00c9d249c942f65b6a48112e6bd6e28a3d15b8a1d35e935621657b3d837
mysqld_exporter:
archive:
source_hash: 38605ae648f8def07a0f412d81a30a6c48c0d20a6981468d25b91c8aa529e599
pushgateway:
archive:
source_hash: 506b555e7a13cabf3d85ec0dbe1bc6bc3a2444c0cc468baa8d31e7fc2fe18dd1
statsd_exporter:
archive:
source_hash: 9362b7482e74792f111c4bb1a372b18a88f6354c78f24713bacfbcb050883556
MacOS:
dir:
default: /etc/defaults
identity:
rootuser: {{ macos_rootuser | d('') }}
rootgroup: {{ macos_rootgroup | d('') }}
kernel: darwin
pkg:
prometheus:
archive_hash: 740e36bcacc0c5d4495f5341fcfa8b7e0dc623d12e8b07ac291052ea0a681325
alertmanager:
archive_hash: efeebaa8e51c521ecb3440345fb65962533cae022d71dff8b127911e893ded2a
blackbox_exporter:
archive_hash: a371d0496adb5d62368d6606928c5effd318d1387f6b9a9998f8d0333492645a
consul_exporter:
archive_hash: 75641783938967c11c18d6d340028ff2dce7ad0ae5e300fa631b813cc6ea9647
graphite_exporter:
archive_hash: f9c0aa745502c0ab01fdcca29181801810202e0aed512a9aa9a37bb4be88a919
haproxy_exporter:
archive_hash: 8fdb8bb182586c57e5892816a02846bae0998916765d22bb81b2c444a3565862
memcached_exporter:
archive_hash: e10685cca5ffd8a3a7574b3dc096dc7418f34906abd399f881be06dd38be62cb
mysqld_exporter:
archive_hash: 8e0a7d8847790d6dcdcf392e6dd227458a7bcaa1e0890cc6326fdf956421f2a7
node_exporter:
archive_hash: 20fadb3108de0a9cc70a1333394e5be90416b4f91025f9fc66f5736335e94398
pushgateway:
archive_hash: 25399a4c6600c1931f9d9bd5294700c2b53f964188b1c6003f9d12a2e176aac1
statsd_exporter:
archive_hash: 15132494523c2b6a89e09b2da63452c8fe587fb82fcc3fd21cc75a4aa2766644
component:
prometheus:
archive:
source_hash: 740e36bcacc0c5d4495f5341fcfa8b7e0dc623d12e8b07ac291052ea0a681325
alertmanager:
archive:
source_hash: efeebaa8e51c521ecb3440345fb65962533cae022d71dff8b127911e893ded2a
blackbox_exporter:
archive:
source_hash: a371d0496adb5d62368d6606928c5effd318d1387f6b9a9998f8d0333492645a
consul_exporter:
archive:
source_hash: 75641783938967c11c18d6d340028ff2dce7ad0ae5e300fa631b813cc6ea9647
graphite_exporter:
archive:
source_hash: f9c0aa745502c0ab01fdcca29181801810202e0aed512a9aa9a37bb4be88a919
haproxy_exporter:
archive:
source_hash: 8fdb8bb182586c57e5892816a02846bae0998916765d22bb81b2c444a3565862
memcached_exporter:
archive:
source_hash: e10685cca5ffd8a3a7574b3dc096dc7418f34906abd399f881be06dd38be62cb
mysqld_exporter:
archive:
source_hash: 8e0a7d8847790d6dcdcf392e6dd227458a7bcaa1e0890cc6326fdf956421f2a7
node_exporter:
archive:
source_hash: 20fadb3108de0a9cc70a1333394e5be90416b4f91025f9fc66f5736335e94398
pushgateway:
archive:
source_hash: 25399a4c6600c1931f9d9bd5294700c2b53f964188b1c6003f9d12a2e176aac1
statsd_exporter:
archive:
source_hash: 15132494523c2b6a89e09b2da63452c8fe587fb82fcc3fd21cc75a4aa2766644

View File

@ -1,27 +1,24 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_config_clean = tplroot ~ '.config.clean' %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- set sls_repo_clean = tplroot ~ '.package.repo.clean' %}
include:
- {{ sls_config_clean }}
{%- if prometheus.use_upstream_repo %}
- .repo.clean
{%- endif %}
- {{ sls_service_clean }}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg %}
{%- for name in p.wanted.component %}
prometheus-package-clean-{{ name }}-removed:
pkg.removed:
- name: {{ name }}
{%- if name in prometheus.service %}
- name: {{ p.pkg.component[name].get('name', name) }}
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
{%- endif %}
- sls: {{ sls_config_clean }}
- sls: {{ sls_service_clean }}
{%- endif %}
{%- endfor %}

View File

@ -1,22 +1,25 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- if prometheus.use_upstream_repo %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- set sls_repo_install = tplroot ~ '.package.repo.install' %}
include:
- .repo
- {{ sls_service_running }}
- {{ sls_repo_install }}
{%- endif %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg %}
{%- for name in p.wanted.component %}
prometheus-package-install-{{ name }}-installed:
pkg.installed:
- name: {{ prometheus.pkg.get(name, {}).get('name', name) }}
- name: {{ p.pkg.component[name].get('name', name) }}
- require:
- sls: {{ sls_repo_install }}
- require_in:
- sls: {{ sls_service_running }}
- reload_modules: true
{%- endif %}
{%- endfor %}

View File

@ -1,16 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg and 'repo' in prometheus.pkg[name] and prometheus.pkg[name]['repo'] %}
{%- if p.pkg.use_upstream_repo and 'repo' in p.pkg and p.pkg.repo %}
prometheus-package-repo-clean-{{ name }}-pkgrepo-absent:
prometheus-package-repo-clean-pkgrepo-managed:
pkgrepo.absent:
- name: {{ prometheus.pkg[name]['repo']['name'] }}
- name: {{ p.pkg['repo']['name'] }}
{%- endif %}
{%- endfor %}
{%- endif %}

View File

@ -1,26 +1,21 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg and 'repo' in prometheus.pkg[name] and prometheus.pkg[name]['repo'] %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
{%- if p.pkg.use_upstream_repo and 'repo' in p.pkg %}
{%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
prometheus-package-repo-install-{{ name }}-pkgrepo-managed:
prometheus-package-repo-install-pkgrepo-managed:
pkgrepo.managed:
{{- format_kwargs(prometheus.pkg[name]['repo']) }}
prometheus-package-repo-install-{{ name }}-file-replace:
# redhat workaround for salt issue #51494
{{- format_kwargs(p.pkg['repo']) }}
file.replace:
- name: /etc/yum.repos.d/{{ name }}.repo
# redhat workaround for salt issue #51494
- name: /etc/yum.repos.d/prometheus.repo
- pattern: ' gpgkey2='
- repl: '\n '
- ignore_if_missing: True
- onlyif: {{ grains.os_family == 'RedHat' }}
{%- endif %}
{%- endfor %}
{%- endif %}

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
include:
- {{ sls_service_clean }}
{%- for name in p.wanted.component %}
{%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
prometheus-service-args-clean-{{ name }}:
file.absent:
- names:
- /tmp/dummy-{{ name }}-dummy
{%- if 'storage.tsdb.path' in p.pkg.component[name]['service']['args'] %}
- {{ p.pkg.component[name]['service']['args']['storage.tsdb.path'] }}
{%- endif %}
- require:
- sls: {{ sls_service_clean }}
{%- if grains.os_family == 'FreeBSD' %}
sysrc.absent:
- names:
- {{ name }}_args
- {{ name }}_listen_address
- {{ name }}_textfile_dir
- {{ name }}_data_dir
- {{ name }}_config
- require:
- sls: {{ sls_service_clean }}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_config_users = tplroot ~ '.config.users' %}
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
{%- set sls_package_install = tplroot ~ '.package.install' %}
include:
- {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }}
- {{ sls_config_users }}
{%- for name in p.wanted.component %}
{%- if 'service' in p.pkg.component[name] and 'args' in p.pkg.component[name]['service'] %}
{%- set args = p.pkg.component[name]['service']['args'] %}
{%- if 'storage.tsdb.path' in args.keys() %}
prometheus-service-args-{{ name }}-data-dir:
file.directory:
- name: {{ args['storage.tsdb.path'] }}
- owner: {{ name }}
- group: {{ name }}
- makedirs: True
- watch_in:
- service: prometheus-service-running-{{ name }}
- require:
- user: prometheus-config-user-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present
{%- endif %}
{%- if grains.os_family == 'FreeBSD' %}
{%- if 'collector.textfile.directory' in args.keys() %}
prometheus-service-args-{{ name }}-collector-textfile-directory:
sysrc.managed:
- name: {{ name }}_textfile_dir
- value: {{ args.pop('collector.textfile.directory') }}
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- if 'storage.tsdb.path' in args.keys() %}
prometheus-service-args-{{ name }}-storage-tsdb-path:
sysrc.managed:
- name: {{ name }}_data_dir
- value: {{ args.pop('storage.tsdb.path') }}
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- if 'web.listen-address' in args.keys() %}
prometheus-service-args-{{ name }}-web-listen-address:
sysrc.managed:
- name: {{ name }}_listen_address
- value: {{ args.pop('web.listen-address') }}
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
prometheus-service-args-{{ name }}-install:
sysrc.managed:
- name: {{ name }}_config
- value: {{ p.dir.etc }}/{{ name }}.yml
- watch_in:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -1,38 +1,36 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
{%- for name in p.wanted.component %}
{%- 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 = prometheus.service.get(name, {}).get('name', False) %}
{%- if not service_name %}
{%- set service_name = name %}
{%- endif %}
prometheus-service-clean-{{ name }}-service-dead:
prometheus-service-clean-{{ name }}:
service.dead:
- name: {{ name }}
- name: {{ service_name }}
- enable: False
{%- if grains.kernel|lower == 'linux' %}
{%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
{%- endif %}
file.absent:
- name: {{ prometheus.dir.service }}/{{ name }}.service
- name: {{ p.dir.service }}/{{ name }}.service
- require:
- service: prometheus-service-clean-{{ name }}-service-dead
- service: prometheus-service-clean-{{ name }}
cmd.run:
- onlyif: {{ grains.kernel|lower == 'linux' }}
- name: systemctl daemon-reload
- require:
- file: prometheus-service-clean-{{ name }}-service-dead
- file: prometheus-service-clean-{{ name }}
{%- if grains.os_family == 'FreeBSD' %}
sysrc.absent:
- name: {{ name }}_environ
- require:
- service: prometheus-service-clean-{{ name }}
{%- endif %}
{%- endif %}
{%- endfor %}
prometheus-config-file-var-file-absent:
file.absent:
- name: {{ prometheus.dir.var }}

View File

@ -2,4 +2,5 @@
# vim: ft=sls
include:
- .args
- .running

View File

@ -1,66 +1,60 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_args = tplroot ~ '.config.args' %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
{%- set sls_config_environ = tplroot ~ '.config.environ' %}
{%- set sls_service_args = tplroot ~ '.service.args.install' %}
include:
- {{ sls_config_args }}
- {{ sls_service_args }}
- {{ sls_config_file }}
- {{ sls_config_environ }}
{%- if 'prometheus' in prometheus.wanted %}
prometheus-config-file-var-file-directory:
file.directory:
- name: {{ prometheus.dir.var }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
- require:
- file: prometheus-config-file-etc-file-directory
{%- endif %}
{%- for name in p.wanted.component %}
{%- 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) %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.service %}
{%- set service_name = prometheus.service.get(name, {}).get('name', False) %}
{%- if not service_name %}
{%- set service_name = name %}
{%- endif %}
{%- if grains.kernel|lower == 'linux' %}
prometheus-service-running-{{ name }}-service-unmasked:
prometheus-service-running-{{ name }}-unmasked:
service.unmasked:
- name: {{ service_name }}
{%- if 'prometheus' in prometheus.wanted %}
- require:
- file: prometheus-config-file-var-file-directory
{%- endif %}
- onlyif:
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
prometheus-service-running-{{ name }}-service-running:
service.running:
- name: {{ service_name }}
- enable: True
{%- if name in prometheus.config %}
- watch:
- file: prometheus-config-file-{{ name }}-file-managed
{%- endif %}
{%- if 'prometheus' in prometheus.wanted %}
- {{ grains.kernel|lower == 'linux' }}
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
- require_in:
- service: prometheus-service-running-{{ name }}
- require:
- file: prometheus-config-file-var-file-directory
{%- endif %}
- sls: {{ sls_service_args }}
- sls: {{ sls_config_file }}
- file: prometheus-config-file-etc-file-directory
prometheus-service-running-{{ name }}:
pkg.installed:
- name: firewalld
- reload_modules: true
- onlyif: {{ grains.kernel|lower == 'linux' }}
service.running:
- names:
- {{ service_name }}
{%- if grains.kernel|lower == 'linux' %}
- service: prometheus-service-running-{{ name }}-service-unmasked
- firewalld
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %}
- enable: True
- require:
- sls: {{ sls_service_args }}
- sls: {{ sls_config_file }}
{%- if p.wanted.firewall %}
firewalld.present:
- name: public
- ports: {{ p.pkg.component[name]['firewall']['ports']|json }}
- onlyif:
- {{ p.wanted.firewall }}
- {{ grains.kernel|lower == 'linux' }}
- require:
- service: prometheus-service-running-{{ name }}
{%- endif %}
{%- endif %}
{%- endfor %}

View File

@ -63,7 +63,7 @@ module.exports = {
}
if (typeof commit.hash === `string`) {
commit.shortHash = commit.hash.substring(0, 7)
commit.hash = commit.hash.substring(0, 7)
}
if (typeof commit.subject === `string`) {

View File

@ -0,0 +1,112 @@
# frozen_string_literal: true
control 'prometheus components' do
title 'should be installed'
# 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 }
its('group') { should eq 'prometheus' }
end
describe directory('/opt/prometheus/prometheus-v2.10.0') do
it { should exist }
its('group') { should eq 'root' }
end
describe file('/opt/prometheus/prometheus-v2.10.0/prometheus') do
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
describe file('/usr/lib/systemd/system/prometheus.service') do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
end
describe directory('/opt/prometheus/alertmanager-v0.17.0') do
it { should exist }
its('group') { should eq 'root' }
end
describe file('/opt/prometheus/alertmanager-v0.17.0/amtool') do
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
describe file('/usr/lib/systemd/system/alertmanager.service') do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
end
describe directory('/opt/prometheus/node_exporter-v0.18.1') do
it { should exist }
its('group') { should eq 'root' }
end
describe file('/opt/prometheus/node_exporter-v0.18.1/node_exporter') do
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
describe file('/usr/lib/systemd/system/node_exporter.service') do
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

View File

@ -1,20 +0,0 @@
control 'Prometheus configuration' do
title 'should match desired lines'
describe file('/etc/prometheus/prometheus.yml') do
it { should be_file }
it { should be_owned_by 'prometheus' }
it { should be_grouped_into 'prometheus' }
its('mode') { should cmp '0644' }
its('content') { should include 'File managed by Salt' }
its('content') { should include 'Your changes may be overwritten.' }
its('content') { should include 'global:' }
its('content') { should include 'alerting:' }
end
describe file('/opt/prometheus/textfile_collectors/ipmitool') do
it { should be_file }
it { should be_owned_by 'root' }
its('mode') { should cmp '0755' }
end
end

View File

@ -1,18 +0,0 @@
control 'prometheus configuration environment' do
title 'should match desired lines'
args_file = case os[:family]
when 'debian'
'/etc/default/prometheus'
else
'/etc/default/prometheus.sh'
end
describe file(args_file) do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its('content') { should include '--web.listen-address=0.0.0.0:9090' }
end
end

View File

@ -1,11 +0,0 @@
control 'Prometheus package' do
title 'should be installed'
describe package('prometheus') do
it { should be_installed }
end
describe package('prometheus-node-exporter') do
it { should be_installed }
end
end

View File

@ -1,10 +0,0 @@
control 'Prometheus service' do
impact 0.5
title 'should be running and enabled'
describe service('prometheus') do
it { should be_enabled }
#it { should be_running } #some ubuntu 16.05 image issue
end
end

View File

@ -1,36 +0,0 @@
title 'linux alternatives profile'
control 'prometheus linux alternatives' do
impact 1.0
title 'should be installed'
desc "Ensure prometheus linux alternatives are correct"
tag: package: "tarball archive"
describe file('/opt/prometheus') do # prometheus-home alternative
it { should be_symlink }
it { should_not be_file }
it { should_not be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('shallow_link_path') { should eq '/etc/alternatives/prometheus-home' }
end
describe file('/usr/bin/prometheus') do # prometheus alternative
it { should be_symlink }
it { should_not be_file }
it { should_not be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('shallow_link_path') { should eq '/etc/alternatives/link-prometheus' }
end
describe file('/usr/bin/promtool') do # promtool alternative
it { should be_symlink }
it { should_not be_file }
it { should_not be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('shallow_link_path') { should eq '/etc/alternatives/link-promtool' }
end
end

View File

@ -1,28 +0,0 @@
title 'prometheus archives profile'
control 'prometheus tarball archive' do
impact 1.0
title 'should be installed'
desc "Ensure prometheus tarball archive was extracted correctly"
describe file('/opt/prometheus-2.10.0.linux-amd64') do
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0755' }
end
require 'digest'
binary = file('/opt/prometheus-2.10.0.linux-amd64/prometheus').content
sha256sum = Digest::SHA256.hexdigest(binary)
describe file('/opt/prometheus-2.10.0.linux-amd64/prometheus') do
its('sha256sum') { should eq '025a7bb0327e1b2b20efbd6e66b8ef81d9020c66f0d5d077b1388a48dec789f7' }
end
binary = file('/opt/prometheus-2.10.0.linux-amd64/promtool').content
sha256sum = Digest::SHA256.hexdigest(binary)
describe file('/opt/prometheus-2.10.0.linux-amd64/promtool') do
its('sha256sum') { should eq 'db004c3c0d6a863929a51da5e1fc4a958668e80256ea2a14c5e461fa13656def' }
end
end

View File

@ -0,0 +1,50 @@
# InSpec Profile: `repo`
This shows the implementation of the `repo` InSpec [profile](https://github.com/inspec/inspec/blob/master/docs/profiles.md).
## Verify a profile
InSpec ships with built-in features to verify a profile structure.
```bash
$ inspec check repo
Summary
-------
Location: repo
Profile: profile
Controls: 4
Timestamp: 2019-06-24T23:09:01+00:00
Valid: true
Errors
------
Warnings
--------
```
## Execute a profile
To run all **supported** controls on a local machine use `inspec exec /path/to/profile`.
```bash
$ inspec exec repo
..
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
8 examples, 0 failures
```
## Execute a specific control from a profile
To run one control from the profile use `inspec exec /path/to/profile --controls name`.
```bash
$ inspec exec repo --controls package
.
Finished in 0.0025 seconds (files took 0.12449 seconds to load)
1 examples, 0 failures
```
See an [example control here](https://github.com/inspec/inspec/blob/master/examples/profile/controls/example.rb).

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
control 'prometheus package' do
title 'should be installed'
describe package('prometheus2') do
it { should be_installed }
end
end

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
name: repo
title: prometheus formula
maintainer: SaltStack Formulas
license: Apache-2.0
summary: Verify that the prometheus formula is setup and configured correctly
supports:
- platform-name: debian
- platform-name: ubuntu
- platform-name: centos
- platform-name: fedora
- platform-name: opensuse
- platform-name: suse
- platform-name: freebsd
- platform-name: amazon
- platform-name: arch

View File

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

193
test/salt/pillar/repo.sls Normal file
View File

@ -0,0 +1,193 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
prometheus:
wanted:
clientlibs:
- golang
- haskell
- rust
component:
- prometheus
- alertmanager # not in debian repo, only archive
- 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: true
use_upstream_archive: false
clientlibs:
# https://prometheus.io/docs/instrumenting/clientlibs
# no bash & perl client tarballs are available
golang:
version: v1.6.0
component:
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'