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

View File

@ -12,6 +12,9 @@ ignore: |
node_modules/ node_modules/
test/**/states/**/*.sls test/**/states/**/*.sls
.kitchen/ .kitchen/
bin/kitchen
prometheus/osfamilymap.yaml
pillar.example
yaml-files: yaml-files:
# Default settings # Default settings
@ -30,7 +33,7 @@ rules:
line-length: line-length:
# Increase from default of `80` # Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
max: 88 max: 98
octal-values: octal-values:
forbid-implicit-octal: true forbid-implicit-octal: true
forbid-explicit-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 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)|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)|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
--- ---
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 # 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 # 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) # FILE PATTERN OWNER(S)
* @NONE * @alxwr
* @noelmcloughlin
# SECTION: Owner(s) for specific directories # SECTION: Owner(s) for specific directories
# FILE PATTERN OWNER(S) # FILE PATTERN OWNER(S)

12
FORMULA
View File

@ -1,9 +1,9 @@
name: prometheus name: prometheus
os: FreeBSD os: Debian, Ubuntu, Raspbian, RedHat, Fedora, CentOS, Amazon, Suse, openSUSE, Gentoo, Funtoo, Arch, Manjaro, Alpine, FreeBSD, OpenBSD, Solaris, SmartOS, Windows, MacOS
os_family: FreeBSD os_family: Debian, RedHat, Suse, Gentoo, Arch, Alpine, FreeBSD, OpenBSD, Solaris, Windows, MacOS
version: 3.3.0 version: 0.2.2
release: 1 release: 1
minimum_version: 2016.11 minimum_version: 2019.2
summary: Prometheus formula summary: prometheus formula
description: Formula to set up Prometheus description: Formula to install prometheus and configure it
top_level_dir: prometheus 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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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/ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub) load(bundle_binstub)
else else
abort( abort('Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
'Your `bin/bundle` was not generated by Bundler, '\ Replace `bin/bundle` by running `bundle binstubs bundler --force`, & run cmd again')
'so this binstub cannot run. Replace `bin/bundle` by running '\
'`bundle binstubs bundler --force`, then run this command again.'
)
end end
end end

View File

@ -15,21 +15,72 @@ This list is sorted by the number of commits per contributor in *descending* ord
- Contributions - 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'>` * - :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>`_ - `@myii <https://github.com/myii>`_
- 43 - 155
* - :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
* - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1800660?v=4' width='36' height='36' alt='@aboe76'>` * - :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>`_ - `@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 - 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'>` * - :raw-html-m2r:`<img class='float-left rounded-1' src='https://avatars0.githubusercontent.com/u/1920805?v=4' width='36' height='36' alt='@alxwr'>`
- `@mgomersbach <https://github.com/mgomersbach>`_ - `@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 - 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: .. _readme:
prometheus-formula prometheus-formula
================ ==================
Formula to manage Prometheus on GNU/Linux and MacOS.
|img_travis| |img_sr| |img_travis| |img_sr|
@ -13,30 +15,32 @@ prometheus-formula
:alt: Semantic Release :alt: Semantic Release
:scale: 100% :scale: 100%
:target: https://github.com/semantic-release/semantic-release :target: https://github.com/semantic-release/semantic-release
Manage Prometheus on MacOS, GNU/Linux and FreeBSD.
.. contents:: **Table of Contents** .. contents:: **Table of Contents**
:depth: 1
General notes General notes
------------- -------------
See the full `SaltStack Formulas installation and usage instructions 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``, Special notes
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. None.
Contributing to this repo Contributing to this repo
------------------------- -------------------------
**Commit message formatting is significant!!** **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:: .. contents::
:local: :local:
@ -46,86 +50,112 @@ Available states
*Meta-state (This is a state that includes other states)*. *Meta-state (This is a state that includes other states)*.
This installs the prometheus package, This installs from prometheus solution.
manages the prometheus configuration file and then
starts the associated prometheus service.
``prometheus.archive`` ``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`` ``prometheus.package``
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus package only. This state will install prometheus component packages from GNU/Linux.
``prometheus.package.repo``
^^^^^^^^^^^^^^^^^^^^^^^^^
This state will install the prometheus package only.
``prometheus.config`` ``prometheus.config``
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
This state will configure the prometheus service and has a dependency on ``prometheus.install`` This state will apply prometheus service configuration (files).
via include list.
``prometheus.service`` ``prometheus.service``
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
This state will start the prometheus service and has a dependency on ``prometheus.config`` This state will start prometheus component services.
via include list.
``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. ``prometheus.exporters.clean``
stops the service, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
removes the configuration file and
then uninstalls the package. This state will remove prometheus exporters configuration.
``prometheus.service.clean`` ``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`` ``prometheus.config.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the configuration of the prometheus service and has a This state will remove prometheus service configuration (files).
dependency on ``prometheus.service.clean`` via include list.
``prometheus.package.clean`` ``prometheus.package.clean``
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will remove the prometheus package and has a depency on This state will uninstall prometheus component packages from GNU/Linux.
``prometheus.config.clean`` via include list.
``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: driver:
image: netmanagers/salt-master-py3:amazonlinux-2 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` ## SALT `2019.2`
- name: debian-10-2019-2-py3 - name: debian-10-2019-2-py3
driver: driver:
@ -46,9 +87,15 @@ platforms:
- name: ubuntu-1804-2019-2-py3 - name: ubuntu-1804-2019-2-py3
driver: driver:
image: netmanagers/salt-2019.2-py3:ubuntu-18.04 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 - name: centos-8-2019-2-py3
driver: driver:
image: netmanagers/salt-2019.2-py3:centos-8 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 - name: fedora-31-2019-2-py3
driver: driver:
image: netmanagers/salt-2019.2-py3:fedora-31 image: netmanagers/salt-2019.2-py3:fedora-31
@ -60,78 +107,22 @@ platforms:
# => SCP did not finish successfully (255): (Net::SCP::Error) # => SCP did not finish successfully (255): (Net::SCP::Error)
transport: transport:
max_ssh_sessions: 1 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 - name: amazonlinux-2-2019-2-py3
driver: driver:
image: netmanagers/salt-2019.2-py3:amazonlinux-2 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 - name: arch-base-latest-2019-2-py2
driver: driver:
image: netmanagers/salt-2019.2-py2:arch-base-latest image: netmanagers/salt-2019.2-py2:arch-base-latest
run_command: /usr/lib/systemd/systemd 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: provisioner:
name: salt_solo name: salt_solo
log_level: debug log_level: debug
@ -156,6 +147,7 @@ suites:
state_top: state_top:
base: base:
'*': '*':
# prometheus.clean
- prometheus - prometheus
pillars: pillars:
top.sls: top.sls:
@ -163,7 +155,24 @@ suites:
'*': '*':
- prometheus - prometheus
pillars_from_files: pillars_from_files:
prometheus.sls: pillar.example prometheus.sls: test/salt/pillar/default.sls
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/default - 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,127 +3,42 @@
--- ---
prometheus: prometheus:
wanted: wanted:
clientlibs:
- golang
- haskell
- rust
component:
- prometheus - prometheus
{%- if grains.os_family not in ('Debian',) %} - alertmanager # not in debian repo, only archive
- alertmanager
{%- endif %}
- node_exporter - node_exporter
# no memcached_exporter in upstream repo - only archive # - memcached_exporter # not in upstream repo, only archive
# memcached_exporter
use_upstream_archive: false exporters:
{%- 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"
node_exporter: node_exporter:
args: textfile_collectors_dependencies: []
web.listen-address: ":9110" textfile_collectors:
# collector.textfile.directory: /var/tmp/node_exporter ipmitool:
enable: false
tofs: remove: false
# The files_switch key serves as a selector for alternative pkg: ipmitool
# directories under the formula files directory. See TOFS pattern smartmon:
# doc for more info. enable: false
# Note: Any value not evaluated by `config.get` will be used literally. remove: false
# This can be used to set custom paths, as many levels deep as required. pkg: smartmontools
files_switch: bash_pkg: bash
- any/path/can/be/used/here smartctl: /usr/sbin/smartctl
- id pkg:
- osfinger use_upstream_repo: false
- os use_upstream_archive: true
- 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'
# 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.
clientlibs:
# https://prometheus.io/docs/instrumenting/clientlibs
# no bash & perl client tarballs are available
golang:
version: v1.6.0
component:
alertmanager: alertmanager:
config:
# yamllint disable-line rule:line-length # yamllint disable-line rule:line-length
# ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml # ref https://github.com/prometheus/alertmanager/blob/master/config/testdata/conf.good.yml
global: global:
@ -163,20 +78,114 @@ prometheus:
- channel: '#my-channel' - channel: '#my-channel'
image_url: 'http://some.img.com/img.png' 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: linux:
# 'Alternatives system' priority: zero disables (default) # 'Alternatives system' priority: zero disables (default)
# yamllint disable-line rule:braces # yamllint disable-line rule:braces
altpriority: {{ range(1, 9100000) | random }} altpriority: {{ range(1, 9100000) | random }}
exporters: tofs:
node_exporter: # The files_switch key serves as a selector for alternative
textfile_collectors: # directories under the formula files directory. See TOFS pattern
ipmitool: # doc for more info
# You must enable individual collectors # Note: Any value not evaluated by `config.get` will be used literally
enable: true # This can be used to set custom paths, as many levels deep as required
# pkg: ipmitool files_switch:
smartmon: - any/path/can/be/used/here
enable: true - id
# pkg: smartmontools - osfinger
# bash_pkg: bash - os
# smartctl: /usr/sbin/smartctl - os_family
# All aspects of path/file resolution are customisable using the options below
# This is unnecessary in most cases; there are sensible defaults
# path_prefix: prometheus_alt
# dirs:
# files: files_alt
# default: default_alt
source_files:
prometheus-config-file-file-managed:
- 'alt_config.yml.jinja'
prometheus-archive-install-managed-service:
- 'alt_systemd.ini.jinja'

View File

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

View File

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

View File

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

View File

@ -1,35 +1,43 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %} {%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
{%- set sls_users_clean = tplroot ~ '.config.users.clean' %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set sls_service_clean = tplroot ~ '.service.clean' %}
include: include:
- {{ sls_users_clean }}
- {{ sls_service_clean }} - {{ sls_service_clean }}
- {{ sls_alternatives_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: file.absent:
- names: - names:
- {{ p.dir.basedir }}/{{ name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) }} - {{ p.dir.symlink }}/bin/{{ cmd }}
- {{ p.dir.symlink }}/sbin/{{ cmd }}
prometheus-archive-clean-{{ name }}-user-absent: - {{ p.dir.var }}/{{ name }}
user.absent: - {{ p.dir.service }}/{{ name }}.service
- name: {{ name }}
group.absent:
- name: {{ name }}
- require: - 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 %} {%- endfor %}
{%- endif %}
prometheus-archive-clean-basedir-file-directory: {%- endif %}
file.absent: {%- endfor %}
- name: {{ p.dir.basedir }}

View File

@ -1,11 +1,10 @@
#.-*- coding: utf-8 -*- #.-*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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: include:
- .install - .install

View File

@ -1,70 +1,99 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- 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 %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{%- set sls_users_install = tplroot ~ '.config.users' %} {%- set sls_config_users = tplroot ~ '.config.users' %}
include: 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: file.directory:
- name: {{ p.dir.basedir }} - name: {{ p.dir.var }}
- user: prometheus - user: prometheus
- group: prometheus - group: prometheus
- mode: 755 - mode: 755
- makedirs: True - makedirs: True
- require: - require:
- sls: '{{ sls_users_install }}.*' - sls: {{ sls_config_users }}
{%- for name in p.wanted %} {%- for name in p.wanted.component %}
{%- if name in p.pkg %}
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
prometheus-archive-install-{{ name }}-archive-extracted: prometheus-archive-install-{{ name }}:
archive.extracted: file.directory:
- name: {{ p.dir.basedir }} - name: {{ p.pkg.component[name]['path'] }}
- source: {{ p.archive.uri }}/{{ name }}/releases/download/v{{ p.pkg[name]['archive_version'] - user: {{ p.identity.rootuser }}
+ '/' + bundle + '.' + p.archive.suffix }} - group: {{ p.identity.rootgroup }}
- source_hash: {{ p.pkg[name]['archive_hash'] }} - mode: '0755'
- user: {{ name }} - makedirs: True
- group: {{ name }} - require:
{{- format_kwargs(p.archive.kwargs) }} - file: prometheus-archive-install-prerequisites
- require_in:
- archive: prometheus-archive-install-{{ name }}
- recurse: - recurse:
- user - user
- group - 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: - 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: prometheus-archive-install-{{ name }}-file-directory:
file.directory: file.directory:
- name: {{ p.dir.var }}/{{ name }} - name: {{ p.dir.var }}/{{ name }}
- user: {{ name }} - user: {{ name }}
- group: {{ name }} - group: {{ name }}
- mode: 755 - mode: '0755'
- makedirs: True - makedirs: True
- require: - require:
- archive: prometheus-archive-install-{{ name }}-archive-extracted - user: prometheus-config-user-install-{{ name }}-user-present
- file: prometheus-config-file-basedir-file-directory - 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: prometheus-archive-install-{{ name }}-managed-service:
file.managed: file.managed:
- name: {{ p.dir.service }}/{{ name }}.service - name: {{ p.dir.service }}/{{ name }}.service
- source: {{ files_switch(['systemd.ini.jinja'], - source: {{ files_switch(['systemd.ini.jinja'],
lookup='prometheus-archive-install-managed-service' lookup='prometheus-archive-install-' ~ name ~ '-managed-service'
) )
}} }}
- mode: 644 - mode: '0644'
- user: root - user: {{ p.identity.rootuser }}
- group: {{ p.rootgroup }} - group: {{ p.identity.rootgroup }}
- makedirs: True - makedirs: True
- template: jinja - template: jinja
- context: - context:
@ -73,17 +102,22 @@ prometheus-archive-install-{{ name }}-managed-service:
user: {{ name }} user: {{ name }}
group: {{ name }} group: {{ name }}
workdir: {{ p.dir.var }}/{{ name }} workdir: {{ p.dir.var }}/{{ name }}
start: {{ p.dir.basedir }}/{{ bundle }}/{{ name }} --config.file {{ p.dir.etc }}/{{ name }}.yml stop: ''
stop: '' #not needed {%- 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: - require:
- file: prometheus-archive-install-{{ name }}-file-directory - 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: cmd.run:
- name: systemctl daemon-reload - name: systemctl daemon-reload
- require: - require:
- file: prometheus-archive-install-{{ name }}-managed-service - archive: prometheus-archive-install-{{ name }}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*- #.-*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
include: include:
- .service.clean - .service.clean
- .config.clean - .config.clean
- .exporters.clean
- .clientlibs.clean
- .archive.clean - .archive.clean
- .package.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 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # 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: include:
- .file.clean - {{ sls_service_clean }}
- .args.clean
- .users.clean {%- for name in p.wanted.component %}
- .node_exporter.textfile_collectors.clean
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 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
include: include:
- .users
- .args
- .file - .file
{%- if 'node_exporter' in prometheus.wanted %} - .environ
- .node_exporter.textfile_collectors
{%- endif %}

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 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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: prometheus-config-user-install-{{ name }}-user-present:
group.present: group.present:

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,49 +2,32 @@
# vim: ft=yaml # vim: ft=yaml
--- ---
prometheus: 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: wanted:
clientlibs:
- golang
component:
- prometheus - prometheus
- alertmanager - alertmanager
- node_exporter - node_exporter
# memcached_exporter # only available as archive
firewall: false # disabled for travis ci
dir: dir:
basedir: /opt/prometheus default: /etc/default
archive: /opt/prometheus
etc: /etc/prometheus etc: /etc/prometheus
var: /var/lib/prometheus
args: /etc/default
args_setting: ARGS
service: /usr/lib/systemd/system service: /usr/lib/systemd/system
textfile_collectors: /opt/prometheus/textfile_collectors symlink: /usr/local
tmp: /tmp/prometheus
service: var: /var/lib/prometheus
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: {}
pkg: pkg:
prometheus: uri: https://github.com/prometheus
archive_version: '2.10.0' use_upstream_repo: false
archive_hash: f4233783826f18606b79e5cef0686e4a9c2030146a3c7ce134f0add09f5adcb7 use_upstream_package: true
binaries: use_upstream_archive: false
- prometheus deps:
- promtool - gzip
- tar
repo: repo:
humanname: prometheus humanname: prometheus
name: prometheus name: prometheus
@ -52,85 +35,253 @@ prometheus:
- installed by salt - installed by salt
enabled: 1 enabled: 1
gpgcheck: 1 gpgcheck: 1
component:
alertmanager: alertmanager:
archive_version: '0.17.0' version: v0.17.0
archive_hash: 7c8d2cfeb021c80881ae9904d959131091b8785b6fda9800f84ddef148fe0a4f config_file: /etc/prometheus/alertmanager.yml
binaries: 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 - amtool
- alertmanager - alertmanager
blackbox_exporter: blackbox_exporter:
archive_version: '0.14.0' version: v0.14.0
archive_hash: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117 config_file: /etc/prometheus/blackbox_exporter.yml
binaries: config: {}
- 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: archive:
uri: https://github.com/prometheus source_hash: a2918a059023045cafb911272c88a9eb83cdac9a8a5e8e74844b5d6d27f19117
suffix: tar.gz commands:
kwargs: - blackbox_exporter
trim_output: true firewall:
enforce_toplevel: true ports:
archive_format: tar - tcp/9110
retry: 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 attempts: 3
until: true until: true
interval: 60 interval: 60
splay: 10 splay: 10
linux: linux:
altpriority: 0 ## 'Alternatives system' priority: zero disables (default) altpriority: 0
kernel: linux
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

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. # Your changes may be overwritten.
######################################################################## ########################################################################
{%- if defaults %} {{ config|yaml(False) }}
{%- for item in defaults %}
{{ item }}
{%- endfor %}
{%- endif %}

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 # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import prometheus with context %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
include: include:
- {{ '.archive' if prometheus.use_upstream_archive else '.package' }} - {{ '.archive' if p.pkg.use_upstream_archive else '.package' }}
- .config - .config
- .service - .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, lookup=None,
default_files_switch=['id', 'os_family'], default_files_switch=['id', 'os_family'],
indent_width=6, indent_width=6,
use_subpath=False) %} v1_path_prefix='') %}
{#- {#-
Returns a valid value for the "source" parameter of a "file.managed" Returns a valid value for the "source" parameter of a "file.managed"
state function. This makes easier the usage of the Template Override and state function. This makes easier the usage of the Template Override and
@ -10,15 +10,15 @@
Params: Params:
* source_files: ordered list of files to look for * 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 list of source files
* default_files_switch: if there's no config (e.g. pillar) * default_files_switch: if there's no config (e.g. pillar)
'<tplroot>:tofs:files_switch' this is the ordered list of grains to '<tplroot>:tofs:files_switch' this is the ordered list of grains to
use as selector switch of the directories under use as selector switch of the directories under
"<path_prefix>/files" "<path_prefix>/files"
* indent_width: indentation of the result value to conform to YAML * indent_witdh: indentation of the result value to conform to YAML
* use_subpath: defaults to `False` but if set, lookup the source file * v1_path_prefix: (deprecated) only used for injecting a path prefix into
recursively from the current state directory up to `tplroot` the source, to support older TOFS configs
Example (based on a `tplroot` of `xxx`): Example (based on a `tplroot` of `xxx`):
@ -55,24 +55,20 @@
tplroot ~ ':tofs:files_switch', tplroot ~ ':tofs:files_switch',
default_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']( {%- set src_files = salt['config.get'](
tplroot ~ ':tofs:source_files:' ~ lookup, 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 #} {#- Only add to [''] when supporting older TOFS implementations #}
{%- set path_prefix_exts = [''] %} {%- set path_prefix_exts = [''] %}
{%- if use_subpath and tplroot != tpldir %} {%- if v1_path_prefix != '' %}
{#- Walk directory tree to find {{ files_dir }} #} {%- do path_prefix_exts.append(v1_path_prefix) %}
{%- 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 %}
{%- endif %} {%- 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 %} {%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
{#- For older TOFS implementation, use `files_switch` from the config #} {#- For older TOFS implementation, use `files_switch` from the config #}
{#- Use the default, new method otherwise #} {#- Use the default, new method otherwise #}
@ -82,21 +78,15 @@
) %} ) %}
{#- Append an empty value to evaluate as `default` in the loop below #} {#- Append an empty value to evaluate as `default` in the loop below #}
{%- if '' not in fsl %} {%- if '' not in fsl %}
{%- set fsl = fsl + [''] %} {%- do fsl.append('') %}
{%- endif %} {%- endif %}
{%- for fs in fsl %} {%- for fs in fsl %}
{%- for src_file in src_files %} {%- for src_file in src_files %}
{%- if fs %} {%- if fs %}
{%- set fs_dirs = salt['config.get'](fs, fs) %} {%- set fs_dir = salt['config.get'](fs, fs) %}
{%- else %} {%- else %}
{%- set fs_dirs = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %} {%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
{%- endif %} {%- 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 = [ {%- set url = [
'- salt:/', '- salt:/',
path_prefix_inc_ext.strip('/'), path_prefix_inc_ext.strip('/'),
@ -108,5 +98,4 @@
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
{%- endfor %}
{%- endmacro %} {%- endmacro %}

View File

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

View File

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

View File

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

View File

@ -1,22 +1,25 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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: include:
- .repo - {{ sls_service_running }}
- {{ sls_repo_install }}
{%- endif %} {%- for name in p.wanted.component %}
{%- for name in prometheus.wanted %}
{%- if name in prometheus.pkg %}
prometheus-package-install-{{ name }}-installed: prometheus-package-install-{{ name }}-installed:
pkg.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 %} {%- endfor %}

View File

@ -1,16 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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 p.pkg.use_upstream_repo and 'repo' in p.pkg and p.pkg.repo %}
{%- if name in prometheus.pkg and 'repo' in prometheus.pkg[name] and prometheus.pkg[name]['repo'] %}
prometheus-package-repo-clean-{{ name }}-pkgrepo-absent: prometheus-package-repo-clean-pkgrepo-managed:
pkgrepo.absent: pkgrepo.absent:
- name: {{ prometheus.pkg[name]['repo']['name'] }} - name: {{ p.pkg['repo']['name'] }}
{%- endif %} {%- endif %}
{%- endfor %}

View File

@ -1,26 +1,21 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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 p.pkg.use_upstream_repo and 'repo' in p.pkg %}
{%- if name in prometheus.pkg and 'repo' in prometheus.pkg[name] and prometheus.pkg[name]['repo'] %} {%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
prometheus-package-repo-install-{{ name }}-pkgrepo-managed: prometheus-package-repo-install-pkgrepo-managed:
pkgrepo.managed: pkgrepo.managed:
{{- format_kwargs(prometheus.pkg[name]['repo']) }} {{- format_kwargs(p.pkg['repo']) }}
prometheus-package-repo-install-{{ name }}-file-replace:
# redhat workaround for salt issue #51494
file.replace: file.replace:
- name: /etc/yum.repos.d/{{ name }}.repo # redhat workaround for salt issue #51494
- name: /etc/yum.repos.d/prometheus.repo
- pattern: ' gpgkey2=' - pattern: ' gpgkey2='
- repl: '\n ' - repl: '\n '
- ignore_if_missing: True - ignore_if_missing: True
- onlyif: {{ grains.os_family == 'RedHat' }} - onlyif: {{ grains.os_family == 'RedHat' }}
{%- endif %} {%- endif %}
{%- 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 ~ "/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 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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 %}
{%- if name in prometheus.service %} {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
{%- set service_name = p.pkg.component[name]['service']['get'](name, {}).get('name', name) %}
{%- set service_name = prometheus.service.get(name, {}).get('name', False) %} prometheus-service-clean-{{ name }}:
{%- if not service_name %}
{%- set service_name = name %}
{%- endif %}
prometheus-service-clean-{{ name }}-service-dead:
service.dead: service.dead:
- name: {{ name }} - name: {{ service_name }}
- enable: False - enable: False
{%- if grains.kernel|lower == 'linux' %} {%- if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1 - onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %} {%- endif %}
file.absent: file.absent:
- name: {{ prometheus.dir.service }}/{{ name }}.service - name: {{ p.dir.service }}/{{ name }}.service
- require: - require:
- service: prometheus-service-clean-{{ name }}-service-dead - service: prometheus-service-clean-{{ name }}
cmd.run: cmd.run:
- onlyif: {{ grains.kernel|lower == 'linux' }} - onlyif: {{ grains.kernel|lower == 'linux' }}
- name: systemctl daemon-reload - name: systemctl daemon-reload
- require: - 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 %}
{%- endif %}
{%- endfor %} {%- endfor %}
prometheus-config-file-var-file-absent:
file.absent:
- name: {{ prometheus.dir.var }}

View File

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

View File

@ -1,66 +1,60 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=sls # vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %} {%- 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' %} {%- 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: include:
- {{ sls_config_args }} - {{ sls_service_args }}
- {{ sls_config_file }} - {{ sls_config_file }}
- {{ sls_config_environ }}
{%- if 'prometheus' in prometheus.wanted %} {%- for name in p.wanted.component %}
prometheus-config-file-var-file-directory: {%- if 'service' in p.pkg.component[name] and p.pkg.component[name]['service'] %}
file.directory: {%- set service_name = p.pkg.component[name]['service']['get'](name, {}).get('name', name) %}
- name: {{ prometheus.dir.var }}
- user: prometheus
- group: prometheus
- mode: 755
- makedirs: True
- require:
- file: prometheus-config-file-etc-file-directory
{%- endif %}
{%- for name in prometheus.wanted %} prometheus-service-running-{{ name }}-unmasked:
{%- 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:
service.unmasked: service.unmasked:
- name: {{ service_name }} - name: {{ service_name }}
{%- if 'prometheus' in prometheus.wanted %}
- require:
- file: prometheus-config-file-var-file-directory
{%- endif %}
- onlyif: - onlyif:
- {{ grains.kernel|lower == 'linux' }}
- systemctl list-units | grep {{ service_name }} >/dev/null 2>&1 - systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %} - require_in:
- service: prometheus-service-running-{{ name }}
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 %}
- require: - require:
- file: prometheus-config-file-var-file-directory - sls: {{ sls_service_args }}
{%- endif %} - 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' %} {%- if grains.kernel|lower == 'linux' %}
- service: prometheus-service-running-{{ name }}-service-unmasked - firewalld
- onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1 - onlyif: systemctl list-units | grep {{ service_name }} >/dev/null 2>&1
{%- endif %} {%- 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 %} {%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -63,7 +63,7 @@ module.exports = {
} }
if (typeof commit.hash === `string`) { if (typeof commit.hash === `string`) {
commit.shortHash = commit.hash.substring(0, 7) commit.hash = commit.hash.substring(0, 7)
} }
if (typeof commit.subject === `string`) { 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'