From c7c5df62d415f4a11ab956a066136fe9a2c20ab3 Mon Sep 17 00:00:00 2001 From: tingwei Date: Thu, 7 Nov 2024 18:12:07 +0800 Subject: [PATCH 1/4] change submodule to directory --- .gitmodules | 4 +- roles/prometheus | 1 - roles/prometheus/.ansible-lint | 5 + roles/prometheus/.gitignore | 7 + roles/prometheus/.mergify.yml | 12 + roles/prometheus/.yamllint | 14 + roles/prometheus/CHANGELOG.md | 782 ++++++++++++++++++ roles/prometheus/CONTRIBUTING.md | 97 +++ roles/prometheus/LICENSE | 21 + roles/prometheus/README.md | 156 ++++ roles/prometheus/TROUBLESHOOTING.md | 3 + roles/prometheus/defaults/main.yml | 213 +++++ roles/prometheus/handlers/main.yml | 13 + roles/prometheus/meta/main.yml | 34 + .../molecule/alternative/molecule.yml | 70 ++ .../molecule/alternative/playbook.yml | 84 ++ .../molecule/alternative/prepare.yml | 37 + .../alternative/tests/test_alternative.py | 44 + .../prometheus/molecule/default/molecule.yml | 75 ++ .../prometheus/molecule/default/playbook.yml | 6 + roles/prometheus/molecule/default/prepare.yml | 5 + .../molecule/default/tests/test_default.py | 71 ++ roles/prometheus/molecule/latest/molecule.yml | 35 + roles/prometheus/molecule/latest/playbook.yml | 8 + .../molecule/latest/tests/test_alternative.py | 28 + roles/prometheus/tasks/configure.yml | 60 ++ roles/prometheus/tasks/install.yml | 137 +++ roles/prometheus/tasks/main.yml | 37 + roles/prometheus/tasks/preflight.yml | 114 +++ roles/prometheus/templates/alert.rules.j2 | 6 + .../templates/prometheus.service.j2 | 66 ++ roles/prometheus/templates/prometheus.yml.j2 | 34 + roles/prometheus/test-requirements.txt | 8 + roles/prometheus/vars/centos-8.yml | 4 + roles/prometheus/vars/centos.yml | 4 + roles/prometheus/vars/debian.yml | 4 + roles/prometheus/vars/fedora.yml | 4 + roles/prometheus/vars/main.yml | 10 + roles/prometheus/vars/redhat-8.yml | 4 + roles/prometheus/vars/redhat.yml | 4 + 40 files changed, 2317 insertions(+), 4 deletions(-) delete mode 160000 roles/prometheus create mode 100644 roles/prometheus/.ansible-lint create mode 100644 roles/prometheus/.gitignore create mode 100644 roles/prometheus/.mergify.yml create mode 100644 roles/prometheus/.yamllint create mode 100644 roles/prometheus/CHANGELOG.md create mode 100644 roles/prometheus/CONTRIBUTING.md create mode 100644 roles/prometheus/LICENSE create mode 100644 roles/prometheus/README.md create mode 100644 roles/prometheus/TROUBLESHOOTING.md create mode 100644 roles/prometheus/defaults/main.yml create mode 100644 roles/prometheus/handlers/main.yml create mode 100644 roles/prometheus/meta/main.yml create mode 100644 roles/prometheus/molecule/alternative/molecule.yml create mode 100644 roles/prometheus/molecule/alternative/playbook.yml create mode 100644 roles/prometheus/molecule/alternative/prepare.yml create mode 100644 roles/prometheus/molecule/alternative/tests/test_alternative.py create mode 100644 roles/prometheus/molecule/default/molecule.yml create mode 100644 roles/prometheus/molecule/default/playbook.yml create mode 100644 roles/prometheus/molecule/default/prepare.yml create mode 100644 roles/prometheus/molecule/default/tests/test_default.py create mode 100644 roles/prometheus/molecule/latest/molecule.yml create mode 100644 roles/prometheus/molecule/latest/playbook.yml create mode 100644 roles/prometheus/molecule/latest/tests/test_alternative.py create mode 100644 roles/prometheus/tasks/configure.yml create mode 100644 roles/prometheus/tasks/install.yml create mode 100644 roles/prometheus/tasks/main.yml create mode 100644 roles/prometheus/tasks/preflight.yml create mode 100644 roles/prometheus/templates/alert.rules.j2 create mode 100644 roles/prometheus/templates/prometheus.service.j2 create mode 100644 roles/prometheus/templates/prometheus.yml.j2 create mode 100644 roles/prometheus/test-requirements.txt create mode 100644 roles/prometheus/vars/centos-8.yml create mode 100644 roles/prometheus/vars/centos.yml create mode 100644 roles/prometheus/vars/debian.yml create mode 100644 roles/prometheus/vars/fedora.yml create mode 100644 roles/prometheus/vars/main.yml create mode 100644 roles/prometheus/vars/redhat-8.yml create mode 100644 roles/prometheus/vars/redhat.yml diff --git a/.gitmodules b/.gitmodules index b9a6764e..326afcaf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,4 @@ [submodule "roles/ansible-ca-store"] path = roles/ansible-ca-store url = https://github.com/lawliet89/ansible-ca-store.git -[submodule "roles/prometheus"] - path = roles/prometheus - url = https://github.com/cloudalchemy/ansible-prometheus.git + diff --git a/roles/prometheus b/roles/prometheus deleted file mode 160000 index 2201713a..00000000 --- a/roles/prometheus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2201713a60fa4b215c6b15b76c891e32d454d6e2 diff --git a/roles/prometheus/.ansible-lint b/roles/prometheus/.ansible-lint new file mode 100644 index 00000000..ad9fc9f9 --- /dev/null +++ b/roles/prometheus/.ansible-lint @@ -0,0 +1,5 @@ +--- +skip_list: +- '106' +- '204' +- '208' diff --git a/roles/prometheus/.gitignore b/roles/prometheus/.gitignore new file mode 100644 index 00000000..db70ede3 --- /dev/null +++ b/roles/prometheus/.gitignore @@ -0,0 +1,7 @@ +*.retry +*.log +.molecule +.cache +__pycache__/ +.pytest_cache +.tox diff --git a/roles/prometheus/.mergify.yml b/roles/prometheus/.mergify.yml new file mode 100644 index 00000000..877a4825 --- /dev/null +++ b/roles/prometheus/.mergify.yml @@ -0,0 +1,12 @@ +--- +pull_request_rules: + - name: automatic merge and new release from cloudalchemybot + conditions: + - "status-success=Travis CI - Pull Request" + - status-success=WIP + - head~=autoupdate|skeleton + - author=cloudalchemybot + actions: + merge: + method: squash + strict: true diff --git a/roles/prometheus/.yamllint b/roles/prometheus/.yamllint new file mode 100644 index 00000000..8f2e1fa2 --- /dev/null +++ b/roles/prometheus/.yamllint @@ -0,0 +1,14 @@ +--- +extends: default +ignore: | + .github/ + meta/ + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable diff --git a/roles/prometheus/CHANGELOG.md b/roles/prometheus/CHANGELOG.md new file mode 100644 index 00000000..e55a25b4 --- /dev/null +++ b/roles/prometheus/CHANGELOG.md @@ -0,0 +1,782 @@ +# Change Log + +## [**Next release**](https://galaxy.ansible.com/cloudalchemy/prometheus) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#318](https://github.com/cloudalchemy/ansible-prometheus/pull/318) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.16.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-11-04) +**Merged pull requests:** + +- Wait for local file systems before starting prometheus [\#317](https://github.com/cloudalchemy/ansible-prometheus/pull/317) ([bartoszcisek](https://github.com/bartoszcisek)) + +## [2.16.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-10-20) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#316](https://github.com/cloudalchemy/ansible-prometheus/pull/316) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.16.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-09-28) +**Implemented enhancements:** + +- offline support [\#296](https://github.com/cloudalchemy/ansible-prometheus/issues/296) + +**Fixed bugs:** + +- prometheus\_scrape\_configs changes line order [\#310](https://github.com/cloudalchemy/ansible-prometheus/issues/310) +- conf.d folder is provided, but there is no mechanism for using it [\#283](https://github.com/cloudalchemy/ansible-prometheus/issues/283) + +**Closed issues:** + +- You need to install \"jmespath\" prior to running json\_query filter [\#314](https://github.com/cloudalchemy/ansible-prometheus/issues/314) + +**Merged pull requests:** + +- Bump version [\#315](https://github.com/cloudalchemy/ansible-prometheus/pull/315) ([SuperQ](https://github.com/SuperQ)) +- \[REPO SYNC\] add troubleshooting doc skeleton [\#309](https://github.com/cloudalchemy/ansible-prometheus/pull/309) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#303](https://github.com/cloudalchemy/ansible-prometheus/pull/303) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Do not create unused directory conf.d [\#299](https://github.com/cloudalchemy/ansible-prometheus/pull/299) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#298](https://github.com/cloudalchemy/ansible-prometheus/pull/298) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-06-09) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#293](https://github.com/cloudalchemy/ansible-prometheus/pull/293) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] Add passlib as a test requirement [\#292](https://github.com/cloudalchemy/ansible-prometheus/pull/292) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-09) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#290](https://github.com/cloudalchemy/ansible-prometheus/pull/290) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-07) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#289](https://github.com/cloudalchemy/ansible-prometheus/pull/289) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- improve path\_prefix example in defaults [\#266](https://github.com/cloudalchemy/ansible-prometheus/pull/266) ([zxyz](https://github.com/zxyz)) + +## [2.15.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-20) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#284](https://github.com/cloudalchemy/ansible-prometheus/pull/284) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.15.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-14) +**Merged pull requests:** + +- Fix version\_compare filter deprecation [\#282](https://github.com/cloudalchemy/ansible-prometheus/pull/282) ([ecksun](https://github.com/ecksun)) + +## [2.15.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-12) +**Fixed bugs:** + +- Readme variable prometheus\_binaries\_local\_dir [\#279](https://github.com/cloudalchemy/ansible-prometheus/issues/279) + +**Merged pull requests:** + +- Update Readme variable prometheus\_binary\_local\_dir [\#280](https://github.com/cloudalchemy/ansible-prometheus/pull/280) ([asatblurbs](https://github.com/asatblurbs)) +- added installation method config to skip install [\#272](https://github.com/cloudalchemy/ansible-prometheus/pull/272) ([DEvil0000](https://github.com/DEvil0000)) + +## [2.14.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-27) +**Fixed bugs:** + +- CriticalDiskSpace Alert using wrong Metrics [\#275](https://github.com/cloudalchemy/ansible-prometheus/issues/275) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#277](https://github.com/cloudalchemy/ansible-prometheus/pull/277) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- defaults: sync alerts from node-mixin project [\#276](https://github.com/cloudalchemy/ansible-prometheus/pull/276) ([paulfantom](https://github.com/paulfantom)) + +## [2.14.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-25) +**Merged pull requests:** + +- Upstream release update [\#274](https://github.com/cloudalchemy/ansible-prometheus/pull/274) ([paulfantom](https://github.com/paulfantom)) + +## [2.14.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-15) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#265](https://github.com/cloudalchemy/ansible-prometheus/pull/265) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Do not manage system directory [\#263](https://github.com/cloudalchemy/ansible-prometheus/pull/263) ([paulfantom](https://github.com/paulfantom)) +- Add binary install directory [\#259](https://github.com/cloudalchemy/ansible-prometheus/pull/259) ([guimaluf](https://github.com/guimaluf)) + +## [2.13.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-20) +**Merged pull requests:** + +- \[REPO SYNC\] Merge pull request \#4 from cloudalchemy/travis\_fix [\#260](https://github.com/cloudalchemy/ansible-prometheus/pull/260) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Improve checksum fetching [\#254](https://github.com/cloudalchemy/ansible-prometheus/pull/254) ([SuperQ](https://github.com/SuperQ)) + +## [2.13.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-11) +**Fixed bugs:** + +- prometheus\_version: latest =\> failed to get sha256sums.txt [\#230](https://github.com/cloudalchemy/ansible-prometheus/issues/230) + +**Merged pull requests:** + +- Switch user login shell to /usr/sbin/nologin [\#258](https://github.com/cloudalchemy/ansible-prometheus/pull/258) ([paulfantom](https://github.com/paulfantom)) + +## [2.13.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-08) +**Closed issues:** + +- Use python3-libselinux instead of libselinux-python on RHEL8/CentOS8 [\#244](https://github.com/cloudalchemy/ansible-prometheus/issues/244) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#256](https://github.com/cloudalchemy/ansible-prometheus/pull/256) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] use latest available python [\#255](https://github.com/cloudalchemy/ansible-prometheus/pull/255) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#253](https://github.com/cloudalchemy/ansible-prometheus/pull/253) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#252](https://github.com/cloudalchemy/ansible-prometheus/pull/252) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] remove IRC link [\#251](https://github.com/cloudalchemy/ansible-prometheus/pull/251) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Fix typo [\#249](https://github.com/cloudalchemy/ansible-prometheus/pull/249) ([Mehonoshin](https://github.com/Mehonoshin)) +- Add CentOS/CentOS-8 support [\#248](https://github.com/cloudalchemy/ansible-prometheus/pull/248) ([ggatward](https://github.com/ggatward)) +- \[REPO SYNC\] add declarative label sync; add autolabelling PRs [\#243](https://github.com/cloudalchemy/ansible-prometheus/pull/243) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] molecule: use CI images from quay.io instead of dockerhub [\#241](https://github.com/cloudalchemy/ansible-prometheus/pull/241) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add option to propagate binaries without access to internet [\#239](https://github.com/cloudalchemy/ansible-prometheus/pull/239) ([paulfantom](https://github.com/paulfantom)) + +## [2.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-11-13) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#240](https://github.com/cloudalchemy/ansible-prometheus/pull/240) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] Update releaser.sh [\#236](https://github.com/cloudalchemy/ansible-prometheus/pull/236) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- \[REPO SYNC\] add support for CentOS8 [\#233](https://github.com/cloudalchemy/ansible-prometheus/pull/233) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#232](https://github.com/cloudalchemy/ansible-prometheus/pull/232) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-10-05) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#231](https://github.com/cloudalchemy/ansible-prometheus/pull/231) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton [\#227](https://github.com/cloudalchemy/ansible-prometheus/pull/227) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add RHEL8 and debian buster support; remove testing on debian jessie [\#226](https://github.com/cloudalchemy/ansible-prometheus/pull/226) ([paulfantom](https://github.com/paulfantom)) +- Some "false" were incorrectly substituted to "no" [\#225](https://github.com/cloudalchemy/ansible-prometheus/pull/225) ([wzyboy](https://github.com/wzyboy)) +- Update minimum required ansible version [\#224](https://github.com/cloudalchemy/ansible-prometheus/pull/224) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Moving to python 3 and dropping support for python 2.x \(on deployer host\) [\#223](https://github.com/cloudalchemy/ansible-prometheus/pull/223) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-19) +**Implemented enhancements:** + +- Support recording rules without alerts [\#192](https://github.com/cloudalchemy/ansible-prometheus/issues/192) + +**Fixed bugs:** + +- Prometheus failed to start on Ubuntu 18.04: LimitNOFILE: Operation not permitted [\#190](https://github.com/cloudalchemy/ansible-prometheus/issues/190) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#221](https://github.com/cloudalchemy/ansible-prometheus/pull/221) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton [\#220](https://github.com/cloudalchemy/ansible-prometheus/pull/220) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Allow specifying recording rules without alerting configuration [\#212](https://github.com/cloudalchemy/ansible-prometheus/pull/212) ([paulfantom](https://github.com/paulfantom)) + +## [2.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-14) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#219](https://github.com/cloudalchemy/ansible-prometheus/pull/219) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus/prometheus upstream release! [\#217](https://github.com/cloudalchemy/ansible-prometheus/pull/217) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-07-11) +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#216](https://github.com/cloudalchemy/ansible-prometheus/pull/216) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-27) +**Closed issues:** + +- prometheus\_alert\_rules\_files link is broken [\#207](https://github.com/cloudalchemy/ansible-prometheus/issues/207) + +**Merged pull requests:** + +- New prometheus/prometheus upstream release! [\#209](https://github.com/cloudalchemy/ansible-prometheus/pull/209) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- add watchdog and clock skew alerts [\#206](https://github.com/cloudalchemy/ansible-prometheus/pull/206) ([paulfantom](https://github.com/paulfantom)) + +## [2.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-04) +**Fixed bugs:** + +- Default CriticalDiskSpace alert using wrong label? [\#201](https://github.com/cloudalchemy/ansible-prometheus/issues/201) + +**Merged pull requests:** + +- Synchronize files from cloudalchemy/skeleton [\#205](https://github.com/cloudalchemy/ansible-prometheus/pull/205) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Wait for network to be online [\#204](https://github.com/cloudalchemy/ansible-prometheus/pull/204) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#203](https://github.com/cloudalchemy/ansible-prometheus/pull/203) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Update label for CriticalDiskSpace alert expression. [\#202](https://github.com/cloudalchemy/ansible-prometheus/pull/202) ([mjbnz](https://github.com/mjbnz)) +- New prometheus/prometheus upstream release! [\#200](https://github.com/cloudalchemy/ansible-prometheus/pull/200) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.8.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-30) +**Merged pull requests:** + +- set go\_arch as a var instead of calculating it during task execution [\#198](https://github.com/cloudalchemy/ansible-prometheus/pull/198) ([paulfantom](https://github.com/paulfantom)) +- New prometheus/prometheus upstream release! [\#197](https://github.com/cloudalchemy/ansible-prometheus/pull/197) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Synchronize files from cloudalchemy/skeleton. [\#196](https://github.com/cloudalchemy/ansible-prometheus/pull/196) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-23) +**Implemented enhancements:** + +- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) + +**Fixed bugs:** + +- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) + +**Closed issues:** + +- can't create prometheus user again [\#185](https://github.com/cloudalchemy/ansible-prometheus/issues/185) +- Implement Uninstalls based on specific variables [\#181](https://github.com/cloudalchemy/ansible-prometheus/issues/181) +- Allow Multiple blackbox exporters [\#179](https://github.com/cloudalchemy/ansible-prometheus/issues/179) +- Install prometheus using docker [\#173](https://github.com/cloudalchemy/ansible-prometheus/issues/173) + +**Merged pull requests:** + +- New prometheus upstream release! [\#193](https://github.com/cloudalchemy/ansible-prometheus/pull/193) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- prometheus.service.j2: stop using tests as filters [\#191](https://github.com/cloudalchemy/ansible-prometheus/pull/191) ([JordanP](https://github.com/JordanP)) +- Preflight checks refactor [\#189](https://github.com/cloudalchemy/ansible-prometheus/pull/189) ([paulfantom](https://github.com/paulfantom)) +- do not remove '/opt/prometheus' [\#188](https://github.com/cloudalchemy/ansible-prometheus/pull/188) ([paulfantom](https://github.com/paulfantom)) +- Parameterise custom static targets file paths [\#187](https://github.com/cloudalchemy/ansible-prometheus/pull/187) ([hamishforbes](https://github.com/hamishforbes)) +- Make prometheus user owner of prometheus folders [\#174](https://github.com/cloudalchemy/ansible-prometheus/pull/174) ([curantes](https://github.com/curantes)) + +## [2.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-04) +**Merged pull requests:** + +- New prometheus upstream release! [\#186](https://github.com/cloudalchemy/ansible-prometheus/pull/186) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Reworked prometheus\_alert\_rules\_files [\#183](https://github.com/cloudalchemy/ansible-prometheus/pull/183) ([eRadical](https://github.com/eRadical)) +- Separate test scenarios and run "privileged" one only on master branch [\#175](https://github.com/cloudalchemy/ansible-prometheus/pull/175) ([paulfantom](https://github.com/paulfantom)) + +## [2.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-02-19) +**Merged pull requests:** + +- Add support for retention by size [\#182](https://github.com/cloudalchemy/ansible-prometheus/pull/182) ([SuperQ](https://github.com/SuperQ)) + +## [2.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-31) +## [2.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-30) +**Closed issues:** + +- Allow specifying source url for Prometheus archive [\#176](https://github.com/cloudalchemy/ansible-prometheus/issues/176) + +**Merged pull requests:** + +- New prometheus upstream release! [\#178](https://github.com/cloudalchemy/ansible-prometheus/pull/178) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- New prometheus upstream release! [\#172](https://github.com/cloudalchemy/ansible-prometheus/pull/172) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-13) +**Fixed bugs:** + +- Default rules not working correctly [\#157](https://github.com/cloudalchemy/ansible-prometheus/issues/157) + +**Closed issues:** + +- Executable HTML files in consoles and console\_libraries in prometheus\_config\_dir [\#168](https://github.com/cloudalchemy/ansible-prometheus/issues/168) +- Wrong home directory for the prometheus user [\#166](https://github.com/cloudalchemy/ansible-prometheus/issues/166) +- Autostart fails [\#162](https://github.com/cloudalchemy/ansible-prometheus/issues/162) +- prometheus\_alert\_rules are not copied as expected [\#148](https://github.com/cloudalchemy/ansible-prometheus/issues/148) + +**Merged pull requests:** + +- Change permissions of console templates to 0644. [\#171](https://github.com/cloudalchemy/ansible-prometheus/pull/171) ([dreig](https://github.com/dreig)) +- Reuse `prometheus\_db\_dir` as prometheus user home directory [\#170](https://github.com/cloudalchemy/ansible-prometheus/pull/170) ([paulfantom](https://github.com/paulfantom)) +- New prometheus upstream release! [\#167](https://github.com/cloudalchemy/ansible-prometheus/pull/167) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- Alert expression fix [\#161](https://github.com/cloudalchemy/ansible-prometheus/pull/161) ([sjal](https://github.com/sjal)) +- Fix running Dry Mode and improved tag usage [\#160](https://github.com/cloudalchemy/ansible-prometheus/pull/160) ([krzyzakp](https://github.com/krzyzakp)) +- New prometheus upstream release! [\#159](https://github.com/cloudalchemy/ansible-prometheus/pull/159) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-29) +**Closed issues:** + +- When used on GCE with gce\_sd\_config discovery scrape config, the ProtectHome=Yes option prevents Prometheus to discover Google Cloud Instances [\#153](https://github.com/cloudalchemy/ansible-prometheus/issues/153) + +**Merged pull requests:** + +- Add clarification surrounding when the .rules file is copied & where it goes [\#156](https://github.com/cloudalchemy/ansible-prometheus/pull/156) ([wbh1](https://github.com/wbh1)) +- Resolves \#153 prometheus homedir set to /tmp [\#155](https://github.com/cloudalchemy/ansible-prometheus/pull/155) ([michalklempa](https://github.com/michalklempa)) +- Document alert relabeling in README.md [\#152](https://github.com/cloudalchemy/ansible-prometheus/pull/152) ([juliusv](https://github.com/juliusv)) + +## [2.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-07) +**Merged pull requests:** + +- Add support for alert relabeling [\#151](https://github.com/cloudalchemy/ansible-prometheus/pull/151) ([juliusv](https://github.com/juliusv)) + +## [2.3.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-05) +**Merged pull requests:** + +- New prometheus upstream release! [\#150](https://github.com/cloudalchemy/ansible-prometheus/pull/150) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- move to ansible 2.7 [\#149](https://github.com/cloudalchemy/ansible-prometheus/pull/149) ([paulfantom](https://github.com/paulfantom)) +- Fixed adding ansible comment in templates [\#147](https://github.com/cloudalchemy/ansible-prometheus/pull/147) ([carpenterbees](https://github.com/carpenterbees)) +- Updates to set systemd ulimit for files to infinity [\#146](https://github.com/cloudalchemy/ansible-prometheus/pull/146) ([jalev](https://github.com/jalev)) +- New prometheus upstream release! [\#145](https://github.com/cloudalchemy/ansible-prometheus/pull/145) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- update prometheus release [\#143](https://github.com/cloudalchemy/ansible-prometheus/pull/143) ([paulfantom](https://github.com/paulfantom)) +- fix test condition [\#141](https://github.com/cloudalchemy/ansible-prometheus/pull/141) ([paulfantom](https://github.com/paulfantom)) +- New prometheus upstream release! [\#140](https://github.com/cloudalchemy/ansible-prometheus/pull/140) ([cloudalchemybot](https://github.com/cloudalchemybot)) + +## [2.3.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-09-06) +**Merged pull requests:** + +- Missing protocol causes wrong url generated [\#137](https://github.com/cloudalchemy/ansible-prometheus/pull/137) ([sparanoid](https://github.com/sparanoid)) + +## [2.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-08-12) +**Closed issues:** + +- \[Question\] can't specify blackbox as target [\#134](https://github.com/cloudalchemy/ansible-prometheus/issues/134) +- failed parsing YAML File [\#129](https://github.com/cloudalchemy/ansible-prometheus/issues/129) + +**Merged pull requests:** + +- New prometheus upstream release! [\#136](https://github.com/cloudalchemy/ansible-prometheus/pull/136) ([cloudalchemybot](https://github.com/cloudalchemybot)) +- fixed typo [\#133](https://github.com/cloudalchemy/ansible-prometheus/pull/133) ([shibumi](https://github.com/shibumi)) + +## [2.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-15) +**Merged pull requests:** + +- Fix custom rule/target file copy [\#132](https://github.com/cloudalchemy/ansible-prometheus/pull/132) ([SuperQ](https://github.com/SuperQ)) + +## [2.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-01) +**Fixed bugs:** + +- Adding prometheus\_config\_flags\_extra without value [\#127](https://github.com/cloudalchemy/ansible-prometheus/issues/127) + +**Merged pull requests:** + +- use tox, ansible 2.6, and allow using remote docker host [\#130](https://github.com/cloudalchemy/ansible-prometheus/pull/130) ([paulfantom](https://github.com/paulfantom)) + +## [2.2.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-27) +**Merged pull requests:** + +- Allow empty value in config\_flags\_extra [\#128](https://github.com/cloudalchemy/ansible-prometheus/pull/128) ([Turgon37](https://github.com/Turgon37)) +- Allow role being run in check mode [\#126](https://github.com/cloudalchemy/ansible-prometheus/pull/126) ([joelpet](https://github.com/joelpet)) +- add 'tags' support [\#125](https://github.com/cloudalchemy/ansible-prometheus/pull/125) ([soloradish](https://github.com/soloradish)) + +## [2.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-09) +**Merged pull requests:** + +- Prometheus 2.3.0 [\#124](https://github.com/cloudalchemy/ansible-prometheus/pull/124) ([paulfantom](https://github.com/paulfantom)) +- fix prometheus\_targets default value. [\#123](https://github.com/cloudalchemy/ansible-prometheus/pull/123) ([soloradish](https://github.com/soloradish)) + +## [2.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-02) +**Merged pull requests:** + +- Let prometheus rule\_files config always be written [\#122](https://github.com/cloudalchemy/ansible-prometheus/pull/122) ([noraab](https://github.com/noraab)) +- specify file name for dest in get\_url call [\#121](https://github.com/cloudalchemy/ansible-prometheus/pull/121) ([sarphram](https://github.com/sarphram)) + +## [2.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-27) +**Fixed bugs:** + +- fix architecture var parsing [\#119](https://github.com/cloudalchemy/ansible-prometheus/pull/119) ([paulfantom](https://github.com/paulfantom)) + +**Closed issues:** + +- Rate limiter in GitHub API [\#115](https://github.com/cloudalchemy/ansible-prometheus/issues/115) + +**Merged pull requests:** + +- use cloudalchemybot when accessing github api [\#120](https://github.com/cloudalchemy/ansible-prometheus/pull/120) ([paulfantom](https://github.com/paulfantom)) + +## [2.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-25) +**Fixed bugs:** + +- Error creating systemd template [\#116](https://github.com/cloudalchemy/ansible-prometheus/issues/116) + +**Merged pull requests:** + +- Deploy console templates [\#118](https://github.com/cloudalchemy/ansible-prometheus/pull/118) ([SuperQ](https://github.com/SuperQ)) +- fix condition in systemd template [\#117](https://github.com/cloudalchemy/ansible-prometheus/pull/117) ([Morsicus](https://github.com/Morsicus)) + +## [2.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-17) +**Implemented enhancements:** + +- Provide checksum validation [\#104](https://github.com/cloudalchemy/ansible-prometheus/issues/104) +- Move to molecule 2.x [\#93](https://github.com/cloudalchemy/ansible-prometheus/issues/93) +- Hardening systemd unit for additional security [\#110](https://github.com/cloudalchemy/ansible-prometheus/pull/110) ([paulfantom](https://github.com/paulfantom)) + +**Fixed bugs:** + +- Role fails on RedHat if SELinux is disabled [\#111](https://github.com/cloudalchemy/ansible-prometheus/issues/111) +- Can't download release due to Github redirect the request [\#101](https://github.com/cloudalchemy/ansible-prometheus/issues/101) + +**Closed issues:** + +- Explain how `prometheus\_targets` and `prometheus\_scrape\_config` work [\#105](https://github.com/cloudalchemy/ansible-prometheus/issues/105) + +**Merged pull requests:** + +- take care of SELinux only when it is enabled [\#112](https://github.com/cloudalchemy/ansible-prometheus/pull/112) ([paulfantom](https://github.com/paulfantom)) +- add checksum verification [\#109](https://github.com/cloudalchemy/ansible-prometheus/pull/109) ([paulfantom](https://github.com/paulfantom)) +- move to molecule 2.x [\#108](https://github.com/cloudalchemy/ansible-prometheus/pull/108) ([paulfantom](https://github.com/paulfantom)) +- Offer a better IRC Web clients to users [\#107](https://github.com/cloudalchemy/ansible-prometheus/pull/107) ([Porkepix](https://github.com/Porkepix)) +- Explain how to use prometheus\_targets and prometheus\_scrape\_configs [\#114](https://github.com/cloudalchemy/ansible-prometheus/pull/114) ([paulfantom](https://github.com/paulfantom)) +- Remove prometheus 1.8 support [\#113](https://github.com/cloudalchemy/ansible-prometheus/pull/113) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-20) +**Merged pull requests:** + +- Fix version\_compare warnings [\#106](https://github.com/cloudalchemy/ansible-prometheus/pull/106) ([Porkepix](https://github.com/Porkepix)) +- Separate downloading and unpacking prometheus archive [\#102](https://github.com/cloudalchemy/ansible-prometheus/pull/102) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-17) +**Implemented enhancements:** + +- Allow specifying `latest` version [\#90](https://github.com/cloudalchemy/ansible-prometheus/issues/90) + +**Merged pull requests:** + +- fast-finish failed travis builds [\#100](https://github.com/cloudalchemy/ansible-prometheus/pull/100) ([paulfantom](https://github.com/paulfantom)) +- Use inline template for simpler targets population task [\#99](https://github.com/cloudalchemy/ansible-prometheus/pull/99) ([paulfantom](https://github.com/paulfantom)) + +## [1.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-13) +**Merged pull requests:** + +- allow `latest` as prometheus\_version [\#94](https://github.com/cloudalchemy/ansible-prometheus/pull/94) ([paulfantom](https://github.com/paulfantom)) +- add header for auto.sh script [\#92](https://github.com/cloudalchemy/ansible-prometheus/pull/92) ([paulfantom](https://github.com/paulfantom)) +- Add synchronization of changelog and GitHub releases [\#91](https://github.com/cloudalchemy/ansible-prometheus/pull/91) ([paulfantom](https://github.com/paulfantom)) +- CI automation scripts outsourcing [\#89](https://github.com/cloudalchemy/ansible-prometheus/pull/89) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-10) +**Merged pull requests:** + +- use new filter schema [\#88](https://github.com/cloudalchemy/ansible-prometheus/pull/88) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-07) +**Merged pull requests:** + +- Quick fix to allow multi-arch environments support [\#87](https://github.com/cloudalchemy/ansible-prometheus/pull/87) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-05) +**Merged pull requests:** + +- Retry when connecting to external services [\#86](https://github.com/cloudalchemy/ansible-prometheus/pull/86) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-03) +**Merged pull requests:** + +- test parametrization [\#85](https://github.com/cloudalchemy/ansible-prometheus/pull/85) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-26) +**Merged pull requests:** + +- Ubuntu bionic \(18.04\) support [\#82](https://github.com/cloudalchemy/ansible-prometheus/pull/82) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-24) +**Merged pull requests:** + +- ansible 2.5 [\#84](https://github.com/cloudalchemy/ansible-prometheus/pull/84) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-22) +**Merged pull requests:** + +- Modify when-statement to not include jinja2 templating delimiters [\#83](https://github.com/cloudalchemy/ansible-prometheus/pull/83) ([swesterveld](https://github.com/swesterveld)) + +## [1.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) +## [1.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) +**Merged pull requests:** + +- Describe jmespath installation to virtualenv [\#81](https://github.com/cloudalchemy/ansible-prometheus/pull/81) ([bngsudheer](https://github.com/bngsudheer)) +- SELinux support [\#79](https://github.com/cloudalchemy/ansible-prometheus/pull/79) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-09) +**Merged pull requests:** + +- bump prometheus version to 2.2 [\#80](https://github.com/cloudalchemy/ansible-prometheus/pull/80) ([paulfantom](https://github.com/paulfantom)) + +## [1.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-25) +**Implemented enhancements:** + +- Support remote read option [\#73](https://github.com/cloudalchemy/ansible-prometheus/issues/73) +- Run Prometheus server without alertmanager option [\#18](https://github.com/cloudalchemy/ansible-prometheus/issues/18) + +**Fixed bugs:** + +- Wrong directory permissions [\#74](https://github.com/cloudalchemy/ansible-prometheus/issues/74) +- metrics\_path for local Prometheus endpoint [\#19](https://github.com/cloudalchemy/ansible-prometheus/issues/19) +- Wrong indent [\#36](https://github.com/cloudalchemy/ansible-prometheus/pull/36) ([paulfantom](https://github.com/paulfantom)) + +**Closed issues:** + +- Allow multiple targets templates files. [\#58](https://github.com/cloudalchemy/ansible-prometheus/issues/58) +- Outdated documentation [\#1](https://github.com/cloudalchemy/ansible-prometheus/issues/1) + +**Merged pull requests:** + +- Custom target and rule files [\#59](https://github.com/cloudalchemy/ansible-prometheus/pull/59) ([paulfantom](https://github.com/paulfantom)) + +## [0.12.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) +**Merged pull requests:** + +- Fix typo [\#78](https://github.com/cloudalchemy/ansible-prometheus/pull/78) ([swesterveld](https://github.com/swesterveld)) + +## [0.12.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) +**Merged pull requests:** + +- Make Prometheus daemon restart/reload with sudo privileges. [\#77](https://github.com/cloudalchemy/ansible-prometheus/pull/77) ([swesterveld](https://github.com/swesterveld)) + +## [0.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-11) +**Merged pull requests:** + +- add remote\_read functionality [\#76](https://github.com/cloudalchemy/ansible-prometheus/pull/76) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) +**Fixed bugs:** + +- change file permissions and ditch prometheus\_root\_dir [\#75](https://github.com/cloudalchemy/ansible-prometheus/pull/75) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) +**Merged pull requests:** + +- specify which tasks should use superuser permissions [\#72](https://github.com/cloudalchemy/ansible-prometheus/pull/72) ([paulfantom](https://github.com/paulfantom)) +- adapt prometheus binary placement to hier\(7\) [\#71](https://github.com/cloudalchemy/ansible-prometheus/pull/71) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-07) +**Closed issues:** + +- File copy globbing [\#57](https://github.com/cloudalchemy/ansible-prometheus/issues/57) + +**Merged pull requests:** + +- Enable check mode in ansible [\#70](https://github.com/cloudalchemy/ansible-prometheus/pull/70) ([paulfantom](https://github.com/paulfantom)) + +## [0.11.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-06) +## [0.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) +**Merged pull requests:** + +- Add support for remote write [\#69](https://github.com/cloudalchemy/ansible-prometheus/pull/69) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) +**Merged pull requests:** + +- Update ansible versions in tests [\#68](https://github.com/cloudalchemy/ansible-prometheus/pull/68) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-22) +**Merged pull requests:** + +- Set global values to prometheus defaults [\#67](https://github.com/cloudalchemy/ansible-prometheus/pull/67) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-20) +**Implemented enhancements:** + +- Add default CriticalRAMLoad alert rules [\#63](https://github.com/cloudalchemy/ansible-prometheus/issues/63) + +**Merged pull requests:** + +- Prometheus 2.1 [\#66](https://github.com/cloudalchemy/ansible-prometheus/pull/66) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) +**Merged pull requests:** + +- added CriticalRAMLoad [\#65](https://github.com/cloudalchemy/ansible-prometheus/pull/65) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.10.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) +**Merged pull requests:** + +- a little bit of python3 support [\#64](https://github.com/cloudalchemy/ansible-prometheus/pull/64) ([aeber](https://github.com/aeber)) + +## [0.10.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-16) +**Closed issues:** + +- More preflight checks? [\#16](https://github.com/cloudalchemy/ansible-prometheus/issues/16) + +**Merged pull requests:** + +- validate prometheus\_config\_flags\_extra [\#62](https://github.com/cloudalchemy/ansible-prometheus/pull/62) ([paulfantom](https://github.com/paulfantom)) + +## [0.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-15) +**Implemented enhancements:** + +- Support more operating systems in CI pipeline and meta/main.yml [\#42](https://github.com/cloudalchemy/ansible-prometheus/issues/42) + +**Merged pull requests:** + +- \[ci skip\] author info [\#61](https://github.com/cloudalchemy/ansible-prometheus/pull/61) ([paulfantom](https://github.com/paulfantom)) +- multiple target files loaded with file\_sd [\#60](https://github.com/cloudalchemy/ansible-prometheus/pull/60) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-13) +**Merged pull requests:** + +- use custom docker images in CI pipeline [\#43](https://github.com/cloudalchemy/ansible-prometheus/pull/43) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-11) +**Merged pull requests:** + +- cleaner tests [\#55](https://github.com/cloudalchemy/ansible-prometheus/pull/55) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-07) +**Closed issues:** + +- Convert scrape\_configs to simple attribute tree [\#45](https://github.com/cloudalchemy/ansible-prometheus/issues/45) + +**Merged pull requests:** + +- added i386 arch [\#54](https://github.com/cloudalchemy/ansible-prometheus/pull/54) ([rdemachkovych](https://github.com/rdemachkovych)) +- Update README.md [\#53](https://github.com/cloudalchemy/ansible-prometheus/pull/53) ([paulfantom](https://github.com/paulfantom)) + +## [0.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-03) +**Closed issues:** + +- What version of molecule are the tests written for? [\#44](https://github.com/cloudalchemy/ansible-prometheus/issues/44) + +**Merged pull requests:** + +- Update generatetag.sh [\#52](https://github.com/cloudalchemy/ansible-prometheus/pull/52) ([paulfantom](https://github.com/paulfantom)) +- Simplify scrape configs [\#50](https://github.com/cloudalchemy/ansible-prometheus/pull/50) ([SuperQ](https://github.com/SuperQ)) + +## [0.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) +**Merged pull requests:** + +- Docs [\#51](https://github.com/cloudalchemy/ansible-prometheus/pull/51) ([paulfantom](https://github.com/paulfantom)) + +## [0.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) +**Merged pull requests:** + +- Update generatetag.sh [\#49](https://github.com/cloudalchemy/ansible-prometheus/pull/49) ([paulfantom](https://github.com/paulfantom)) +- support older raspberry pi [\#48](https://github.com/cloudalchemy/ansible-prometheus/pull/48) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.14](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-31) +**Merged pull requests:** + +- Add link to demo site [\#47](https://github.com/cloudalchemy/ansible-prometheus/pull/47) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.13](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-30) +**Merged pull requests:** + +- Clean scrape config [\#46](https://github.com/cloudalchemy/ansible-prometheus/pull/46) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) +**Merged pull requests:** + +- armv7l ansible arch translates to armv7 go arch [\#41](https://github.com/cloudalchemy/ansible-prometheus/pull/41) ([anisse](https://github.com/anisse)) + +## [0.7.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) +**Merged pull requests:** + +- storage retention [\#40](https://github.com/cloudalchemy/ansible-prometheus/pull/40) ([paulfantom](https://github.com/paulfantom)) +- change alert rules name; take rules from wildcard [\#38](https://github.com/cloudalchemy/ansible-prometheus/pull/38) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-22) +**Merged pull requests:** + +- Update README.md [\#39](https://github.com/cloudalchemy/ansible-prometheus/pull/39) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-18) +**Implemented enhancements:** + +- metrics\_path for local Prometheus endpoint [\#27](https://github.com/cloudalchemy/ansible-prometheus/issues/27) + +**Merged pull requests:** + +- Fix default port for alertmanager [\#37](https://github.com/cloudalchemy/ansible-prometheus/pull/37) ([paulfantom](https://github.com/paulfantom)) +- do not copy alert rules when there are none [\#35](https://github.com/cloudalchemy/ansible-prometheus/pull/35) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- Issue27 [\#32](https://github.com/cloudalchemy/ansible-prometheus/pull/32) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- add disk usage alert and reboot alert [\#31](https://github.com/cloudalchemy/ansible-prometheus/pull/31) ([paulfantom](https://github.com/paulfantom)) +- add comments; clear README [\#30](https://github.com/cloudalchemy/ansible-prometheus/pull/30) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) +**Merged pull requests:** + +- CI fix [\#29](https://github.com/cloudalchemy/ansible-prometheus/pull/29) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Merged pull requests:** + +- leave empty prometheus\_web\_external\_url for default [\#28](https://github.com/cloudalchemy/ansible-prometheus/pull/28) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.7.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Merged pull requests:** + +- metrics path [\#24](https://github.com/cloudalchemy/ansible-prometheus/pull/24) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) +**Closed issues:** + +- Use systemd for service control [\#25](https://github.com/cloudalchemy/ansible-prometheus/issues/25) + +**Merged pull requests:** + +- fully switch to systemd module [\#26](https://github.com/cloudalchemy/ansible-prometheus/pull/26) ([paulfantom](https://github.com/paulfantom)) +- auto set go architecture [\#23](https://github.com/cloudalchemy/ansible-prometheus/pull/23) ([paulfantom](https://github.com/paulfantom)) +- simplify setting custom configuration file [\#21](https://github.com/cloudalchemy/ansible-prometheus/pull/21) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-08) +**Merged pull requests:** + +- Add newline before \[Unit\] section in service file [\#20](https://github.com/cloudalchemy/ansible-prometheus/pull/20) ([ecksun](https://github.com/ecksun)) + +## [0.7.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-06) +**Closed issues:** + +- Debian support [\#3](https://github.com/cloudalchemy/ansible-prometheus/issues/3) +- Better handling of alerting rules [\#2](https://github.com/cloudalchemy/ansible-prometheus/issues/2) + +**Merged pull requests:** + +- Update README.md [\#17](https://github.com/cloudalchemy/ansible-prometheus/pull/17) ([paulfantom](https://github.com/paulfantom)) +- Typo [\#14](https://github.com/cloudalchemy/ansible-prometheus/pull/14) ([paulfantom](https://github.com/paulfantom)) +- Stop pipeline on any error [\#13](https://github.com/cloudalchemy/ansible-prometheus/pull/13) ([paulfantom](https://github.com/paulfantom)) + +## [0.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) +**Merged pull requests:** + +- Alert rules and debian support [\#11](https://github.com/cloudalchemy/ansible-prometheus/pull/11) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) +**Merged pull requests:** + +- Fix tagging [\#12](https://github.com/cloudalchemy/ansible-prometheus/pull/12) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-30) +**Merged pull requests:** + +- Prometheus job [\#10](https://github.com/cloudalchemy/ansible-prometheus/pull/10) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.6.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Closed issues:** + +- Parallel CI build [\#4](https://github.com/cloudalchemy/ansible-prometheus/issues/4) + +**Merged pull requests:** + +- Update main.yml [\#9](https://github.com/cloudalchemy/ansible-prometheus/pull/9) ([paulfantom](https://github.com/paulfantom)) +- prometheus\_external\_labels variable assignment dynamically [\#6](https://github.com/cloudalchemy/ansible-prometheus/pull/6) ([rdemachkovych](https://github.com/rdemachkovych)) + +## [0.6.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Merged pull requests:** + +- Update generatetag.sh [\#8](https://github.com/cloudalchemy/ansible-prometheus/pull/8) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) +**Merged pull requests:** + +- Update generatetag.sh [\#7](https://github.com/cloudalchemy/ansible-prometheus/pull/7) ([paulfantom](https://github.com/paulfantom)) +- test different ansible versions [\#5](https://github.com/cloudalchemy/ansible-prometheus/pull/5) ([paulfantom](https://github.com/paulfantom)) + +## [0.6.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) +## [0.6.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) +## [0.6.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.6.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) +## [0.5.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) +## [0.5.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) +## [0.5.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-07) +## [0.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-22) +## [0.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-17) +## [0.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-16) +## [0.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-05) +## [0.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-09-27) +## [0.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) +## [0.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) +## [0.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) +## [0.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) +## [0.1.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) +## [0.1.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-10) +## [0.1.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-20) +## [0.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-14) +## [0.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-13) +## [0.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-06) +## [0.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) +## [0.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) +## [0.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-15) +## [0.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) +## [0.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) +## [0.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-04-27) + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/roles/prometheus/CONTRIBUTING.md b/roles/prometheus/CONTRIBUTING.md new file mode 100644 index 00000000..897372dd --- /dev/null +++ b/roles/prometheus/CONTRIBUTING.md @@ -0,0 +1,97 @@ +# Contributor Guideline + +This document provides an overview of how you can participate in improving this project or extending it. We are +grateful for all your help: bug reports and fixes, code contributions, documentation or ideas. Feel free to join, we +appreciate your support!! + +## Communication + +### GitHub repositories + +Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report +bugs, ask questions, and request new features . + +## git and GitHub + +In order to contribute code please: + +1. Fork the project on GitHub +2. Clone the project +3. Add changes (and tests) +4. Commit and push +5. Create a merge-request + +To have your code merged, see the expectations listed below. + +You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo). + +Please follow common commit best-practices. Be explicit, have a short summary, a well-written description and +references. This is especially important for the merge-request. + +Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCommitMessages) and +[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message). + +## Releases + +We try to stick to semantic versioning and our releases are automated. Release is created by assigning a keyword (in a +way similar to travis [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build)) to a +commit with merge request. Available keywords are (square brackets are important!): + +* `[patch]`, `[fix]` - for PATCH version release +* `[minor]`, `[feature]`, `[feat]` - for MINOR version release +* `[major]`, `[breaking change]` - for MAJOR version release + +## Changelog + +Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs +and labels. + +## Expectations + +### Keep it simple + +We try to provide production ready ansible roles which should be as much zero-conf as possible but this doesn't mean to +overcomplicate things. Just follow [KISS](https://en.wikipedia.org/wiki/KISS_principle). + +### Be explicit + +* Please avoid using nonsensical property and variable names. +* Use self-describing attribute names for user configuration. +* In case of failures, communicate what happened and why a failure occurs to the user. Make it easy to track the code +or action that produced the error. Try to catch and handle errors if possible to provide improved failure messages. + + +### Add tests + +We are striving to use at least two test scenarios located in [/molecule](molecule) directory. First one +([default](molecule/default)) is testing default configuration without any additional variables, second one +([alternative](molecule/alternative)) is testing what happens when many variables from +[/defaults/main.yml](defaults/main.yml) are changed. When adding new functionalities please add tests to proper +scenarios. Tests are written in testinfra framework and are located in `/tests` subdirectory of scenario directory +(for example default tests are in [/molecule/default/tests](molecule/default/tests)). +More information about: + - [testinfra](http://testinfra.readthedocs.io/en/latest/index.html) + - [molecule](https://molecule.readthedocs.io/en/latest/index.html) + +### Follow best practices + +Please follow [ansible best practices](http://docs.ansible.com/ansible/latest/playbooks_best_practices.html) and +especially provide meaningful names to tasks and even comments where needed. + +Our test framework automatically lints code with [`yamllint`](https://yamllint.readthedocs.io) and +[`ansible-lint`](https://github.com/willthames/ansible-lint) programs so be sure to follow their rules. + +Remember: Code is generally read much more often than written. + +### Use Markdown + +Wherever possible, please refrain from any other formats and stick to simple markdown. + +## Requirements regarding roles design + +We are trying to create the best and most secure installation method for non-containerized prometheus stack components. +To accomplish this all roles need to support: + +- current and at least one previous ansible version (wherever possible we try to support 2 previous ansible versions) +- systemd as the only available process manager +- at least latest debian and CentOS distributions diff --git a/roles/prometheus/LICENSE b/roles/prometheus/LICENSE new file mode 100644 index 00000000..353992c6 --- /dev/null +++ b/roles/prometheus/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017-2018 Pawel Krupa, Roman Demachkovych + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/roles/prometheus/README.md b/roles/prometheus/README.md new file mode 100644 index 00000000..b3279d36 --- /dev/null +++ b/roles/prometheus/README.md @@ -0,0 +1,156 @@ +

prometheus logo

+ +# Ansible Role: prometheus + +[![Build Status](https://travis-ci.org/cloudalchemy/ansible-prometheus.svg?branch=master)](https://travis-ci.org/cloudalchemy/ansible-prometheus) +[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT) +[![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.prometheus-blue.svg)](https://galaxy.ansible.com/cloudalchemy/prometheus/) +[![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-prometheus.svg)](https://github.com/cloudalchemy/ansible-prometheus/tags) + +## Description + +Deploy [Prometheus](https://github.com/prometheus/prometheus) monitoring system using ansible. + +### Upgradability notice + +When upgrading from <= 2.4.0 version of this role to >= 2.4.1 please turn off your prometheus instance. More in [2.4.1 release notes](https://github.com/cloudalchemy/ansible-prometheus/releases/tag/2.4.1) + +## Requirements + +- Ansible >= 2.7 (It might work on previous versions, but we cannot guarantee it) +- jmespath on deployer machine. If you are using Ansible from a Python virtualenv, install *jmespath* to the same virtualenv via pip. +- gnu-tar on Mac deployer host (`brew install gnu-tar`) + +## Role Variables + +All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below. + +| Name | Default Value | Description | +| -------------- | ------------- | -----------------------------------| +| `prometheus_version` | 2.24.1 | Prometheus package version. Also accepts `latest` as parameter. Only prometheus 2.x is supported | +| `prometheus_skip_install` | false | Prometheus installation tasks gets skipped when set to true. | +| `prometheus_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `prometheus` AND `promtool` binaries are stored on host on which ansible is ran. This overrides `prometheus_version` parameter | +| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration | +| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database | +| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening | +| `prometheus_web_external_url` | "" | External address on which prometheus is available. Useful when behind reverse proxy. Ex. `http://example.org/prometheus` | +| `prometheus_storage_retention` | "30d" | Data retention period | +| `prometheus_storage_retention_size` | "0" | Data retention period by size | +| `prometheus_config_flags_extra` | {} | Additional configuration flags passed to prometheus binary at startup | +| `prometheus_alertmanager_config` | [] | Configuration responsible for pointing where alertmanagers are. This should be specified as list in yaml format. It is compatible with official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config) | +| `prometheus_alert_relabel_configs` | [] | Alert relabeling rules. This should be specified as list in yaml format. It is compatible with the official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alert_relabel_configs) | +| `prometheus_global` | { scrape_interval: 60s, scrape_timeout: 15s, evaluation_interval: 15s } | Prometheus global config. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#configuration-file) | +| `prometheus_remote_write` | [] | Remote write. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | +| `prometheus_remote_read` | [] | Remote read. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | +| `prometheus_external_labels` | environment: "{{ ansible_fqdn \| default(ansible_host) \| default(inventory_hostname) }}" | Provide map of additional labels which will be added to any time series or alerts when communicating with external systems | +| `prometheus_targets` | {} | Targets which will be scraped. Better example is provided in our [demo site](https://github.com/cloudalchemy/demo-site/blob/2a8a56fc10ce613d8b08dc8623230dace6704f9a/group_vars/all/vars#L8) | +| `prometheus_scrape_configs` | [defaults/main.yml#L58](https://github.com/cloudalchemy/ansible-prometheus/blob/ff7830d06ba57be1177f2b6fca33a4dd2d97dc20/defaults/main.yml#L47) | Prometheus scrape jobs provided in same format as in [official docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) | +| `prometheus_config_file` | "prometheus.yml.j2" | Variable used to provide custom prometheus configuration file in form of ansible template | +| `prometheus_alert_rules` | [defaults/main.yml#L81](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L85) | Full list of alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/ansible_managed.rules`. Alerting rules can be also provided by other files located in `{{ prometheus_config_dir }}/rules/` which have `*.rules` extension | +| `prometheus_alert_rules_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L78) | List of folders where ansible will look for files containing alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/`. Files must have `*.rules` extension | +| `prometheus_static_targets_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L81) | List of folders where ansible will look for files containing custom static target configuration files which will be copied to `{{ prometheus_config_dir }}/file_sd/`. | + + +### Relation between `prometheus_scrape_configs` and `prometheus_targets` + +#### Short version + +`prometheus_targets` is just a map used to create multiple files located in "{{ prometheus_config_dir }}/file_sd" directory. Where file names are composed from top-level keys in that map with `.yml` suffix. Those files store [file_sd scrape targets data](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config) and they need to be read in `prometheus_scrape_configs`. + +#### Long version + +A part of *prometheus.yml* configuration file which describes what is scraped by prometheus is stored in `prometheus_scrape_configs`. For this variable same configuration options as described in [prometheus docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) are used. + +Meanwhile `prometheus_targets` is our way of adopting [prometheus scrape type `file_sd`](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#). It defines a map of files with their content. A top-level keys are base names of files which need to have their own scrape job in `prometheus_scrape_configs` and values are a content of those files. + +All this mean that you CAN use custom `prometheus_scrape_configs` with `prometheus_targets` set to `{}`. However when you set anything in `prometheus_targets` it needs to be mapped to `prometheus_scrape_configs`. If it isn't you'll get an error in preflight checks. + +#### Example + +Lets look at our default configuration, which shows all features. By default we have this `prometheus_targets`: +``` +prometheus_targets: + node: # This is a base file name. File is located in "{{ prometheus_config_dir }}/file_sd/<>.yml" + - targets: # + - localhost:9100 # All this is a targets section in file_sd format + labels: # + env: test # +``` +Such config will result in creating one file named `node.yml` in `{{ prometheus_config_dir }}/file_sd` directory. + +Next this file needs to be loaded into scrape config. Here is modified version of our default `prometheus_scrape_configs`: +``` +prometheus_scrape_configs: + - job_name: "prometheus" # Custom scrape job, here using `static_config` + metrics_path: "/metrics" + static_configs: + - targets: + - "localhost:9090" + - job_name: "example-node-file-servicediscovery" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" # This line loads file created from `prometheus_targets` +``` + +## Example + +### Playbook + +```yaml +--- +- hosts: all + roles: + - cloudalchemy.prometheus + vars: + prometheus_targets: + node: + - targets: + - localhost:9100 + - demo.cloudalchemy.org:9100 + labels: + env: demosite +``` + +### Demo site + +Prometheus organization provide a demo site for full monitoring solution based on prometheus and grafana. Repository with code and links to running instances is [available on github](https://github.com/prometheus/demo-site). + +### Defining alerting rules files + +Alerting rules are defined in `prometheus_alert_rules` variable. Format is almost identical to one defined in[ Prometheus 2.0 documentation](https://prometheus.io/docs/prometheus/latest/configuration/template_examples/). +Due to similarities in templating engines, every templates should be wrapped in `{% raw %}` and `{% endraw %}` statements. Example is provided in [defaults/main.yml](defaults/main.yml) file. + +## Local Testing + +The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. +We are using tox to simplify process of testing on multiple ansible versions. To install tox execute: +```sh +pip3 install tox +``` +To run tests on all ansible versions (WARNING: this can take some time) +```sh +tox +``` +To run a custom molecule command on custom environment with only default test scenario: +```sh +tox -e py35-ansible28 -- molecule test -s default +``` +For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/). + +If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests. + +## Travis CI + +Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which will take more time than local testing, so please be patient. + +## Contributing + +See [contributor guideline](CONTRIBUTING.md). + +## Troubleshooting + +See [troubleshooting](TROUBLESHOOTING.md). + +## License + +This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details. diff --git a/roles/prometheus/TROUBLESHOOTING.md b/roles/prometheus/TROUBLESHOOTING.md new file mode 100644 index 00000000..748f6a5f --- /dev/null +++ b/roles/prometheus/TROUBLESHOOTING.md @@ -0,0 +1,3 @@ +# Troubleshooting + + diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml new file mode 100644 index 00000000..dc8a19f1 --- /dev/null +++ b/roles/prometheus/defaults/main.yml @@ -0,0 +1,213 @@ +--- +prometheus_version: 2.24.1 +prometheus_binary_local_dir: '' +prometheus_skip_install: false + +prometheus_config_dir: /etc/prometheus +prometheus_db_dir: /var/lib/prometheus + +prometheus_web_listen_address: "0.0.0.0:9090" +prometheus_web_external_url: '' + +prometheus_storage_retention: "30d" +# Available since Prometheus 2.7.0 +# [EXPERIMENTAL] Maximum number of bytes that can be stored for blocks. Units +# supported: KB, MB, GB, TB, PB. +prometheus_storage_retention_size: "0" + +prometheus_config_flags_extra: {} +# prometheus_config_flags_extra: +# storage.tsdb.retention: 15d +# alertmanager.timeout: 10s + +prometheus_alertmanager_config: [] +# prometheus_alertmanager_config: +# - scheme: https +# path_prefix: alertmanager/ +# basic_auth: +# username: user +# password: pass +# static_configs: +# - targets: ["127.0.0.1:9093"] +# proxy_url: "127.0.0.2" + +prometheus_alert_relabel_configs: [] +# prometheus_alert_relabel_configs: +# - action: labeldrop +# regex: replica + +prometheus_global: + scrape_interval: 15s + scrape_timeout: 10s + evaluation_interval: 15s + +prometheus_remote_write: [] +# prometheus_remote_write: +# - url: https://dev.kausal.co/prom/push +# basic_auth: +# password: FOO + +prometheus_remote_read: [] +# prometheus_remote_read: +# - url: https://demo.cloudalchemy.org:9201/read +# basic_auth: +# password: FOO + +prometheus_external_labels: + environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}" + +prometheus_targets: {} +# node: +# - targets: +# - localhost:9100 +# labels: +# env: test + +prometheus_scrape_configs: + - job_name: "prometheus" + metrics_path: "{{ prometheus_metrics_path }}" + static_configs: + - targets: + - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - job_name: "node" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" + +# Alternative config file name, searched in ansible templates path. +prometheus_config_file: 'prometheus.yml.j2' + +prometheus_alert_rules_files: + - prometheus/rules/*.rules + +prometheus_static_targets_files: + - prometheus/targets/*.yml + - prometheus/targets/*.json + +prometheus_alert_rules: + - alert: Watchdog + expr: vector(1) + for: 10m + labels: + severity: warning + annotations: + description: "This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\n\"DeadMansSnitch\" integration in PagerDuty." + summary: 'Ensure entire alerting pipeline is functional' + - alert: InstanceDown + expr: 'up == 0' + for: 5m + labels: + severity: critical + annotations: + description: '{% raw %}{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.{% endraw %}' + summary: '{% raw %}Instance {{ $labels.instance }} down{% endraw %}' + - alert: RebootRequired + expr: 'node_reboot_required > 0' + labels: + severity: warning + annotations: + description: '{% raw %}{{ $labels.instance }} requires a reboot.{% endraw %}' + summary: '{% raw %}Instance {{ $labels.instance }} - reboot required{% endraw %}' + - alert: NodeFilesystemSpaceFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up.{% endraw %}' + summary: 'Filesystem is predicted to run out of space within the next 24 hours.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemSpaceFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up fast.{% endraw %}' + summary: 'Filesystem is predicted to run out of space within the next 4 hours.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemAlmostOutOfSpace + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' + summary: 'Filesystem has less than 5% space left.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemAlmostOutOfSpace + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' + summary: 'Filesystem has less than 3% space left.' + expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemFilesFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up.{% endraw %}' + summary: 'Filesystem is predicted to run out of inodes within the next 24 hours.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemFilesFillingUp + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up fast.{% endraw %}' + summary: 'Filesystem is predicted to run out of inodes within the next 4 hours.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeFilesystemAlmostOutOfFiles + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' + summary: 'Filesystem has less than 5% inodes left.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: warning + - alert: NodeFilesystemAlmostOutOfFiles + annotations: + description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' + summary: 'Filesystem has less than 3% inodes left.' + expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" + for: 1h + labels: + severity: critical + - alert: NodeNetworkReceiveErrs + annotations: + description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} receive errors in the last two minutes.{% endraw %}' + summary: 'Network interface is reporting many receive errors.' + expr: "increase(node_network_receive_errs_total[2m]) > 10\n" + for: 1h + labels: + severity: warning + - alert: NodeNetworkTransmitErrs + annotations: + description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} transmit errors in the last two minutes.{% endraw %}' + summary: 'Network interface is reporting many transmit errors.' + expr: "increase(node_network_transmit_errs_total[2m]) > 10\n" + for: 1h + labels: + severity: warning + - alert: NodeHighNumberConntrackEntriesUsed + annotations: + description: '{% raw %}{{ $value | humanizePercentage }} of conntrack entries are used{% endraw %}' + summary: 'Number of conntrack are getting close to the limit' + expr: "(node_nf_conntrack_entries / node_nf_conntrack_entries_limit) > 0.75\n" + labels: + severity: warning + - alert: NodeClockSkewDetected + annotations: + message: '{% raw %}Clock on {{ $labels.instance }} is out of sync by more than 300s. Ensure NTP is configured correctly on this host.{% endraw %}' + summary: 'Clock skew detected.' + expr: "(\n node_timex_offset_seconds > 0.05\nand\n deriv(node_timex_offset_seconds[5m]) >= 0\n)\nor\n(\n node_timex_offset_seconds < -0.05\nand\n deriv(node_timex_offset_seconds[5m]) <= 0\n)\n" + for: 10m + labels: + severity: warning + - alert: NodeClockNotSynchronising + annotations: + message: '{% raw %}Clock on {{ $labels.instance }} is not synchronising. Ensure NTP is configured on this host.{% endraw %}' + summary: 'Clock not synchronising.' + expr: "min_over_time(node_timex_sync_status[5m]) == 0\n" + for: 10m + labels: + severity: warning diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml new file mode 100644 index 00000000..aba85189 --- /dev/null +++ b/roles/prometheus/handlers/main.yml @@ -0,0 +1,13 @@ +--- +- name: restart prometheus + become: true + systemd: + daemon_reload: true + name: prometheus + state: restarted + +- name: reload prometheus + become: true + systemd: + name: prometheus + state: reloaded diff --git a/roles/prometheus/meta/main.yml b/roles/prometheus/meta/main.yml new file mode 100644 index 00000000..0fb2b817 --- /dev/null +++ b/roles/prometheus/meta/main.yml @@ -0,0 +1,34 @@ +--- +galaxy_info: + author: Roman Demachkovych, Pawel Krupa + description: Prometheus monitoring system configuration and management + license: MIT + company: none + min_ansible_version: 2.7 + platforms: + - name: Ubuntu + versions: + - bionic + - xenial + - name: Debian + versions: + - stretch + - buster + - name: EL + versions: + - 7 + - 8 + - name: Fedora + versions: + - 30 + - 31 + galaxy_tags: + - monitoring + - prometheus + - metrics + - alerts + - alerting + - molecule + - cloud + +dependencies: [] diff --git a/roles/prometheus/molecule/alternative/molecule.yml b/roles/prometheus/molecule/alternative/molecule.yml new file mode 100644 index 00000000..c03bcf2a --- /dev/null +++ b/roles/prometheus/molecule/alternative/molecule.yml @@ -0,0 +1,70 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: bionic + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: xenial + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: stretch + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-9 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos7 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-7 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos8 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-8 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: playbook.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/alternative/playbook.yml b/roles/prometheus/molecule/alternative/playbook.yml new file mode 100644 index 00000000..68c46b93 --- /dev/null +++ b/roles/prometheus/molecule/alternative/playbook.yml @@ -0,0 +1,84 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus + vars: + prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64' + prometheus_config_dir: /opt/prom/etc + prometheus_db_dir: /opt/prom/lib + prometheus_web_listen_address: "127.0.0.1:9090" + prometheus_web_external_url: "http://127.0.0.1:9090/prometheus" + prometheus_storage_retention: "60d" + prometheus_storage_retention_size: "1GB" + prometheus_config_flags_extra: + alertmanager.timeout: 10s + web.enable-admin-api: + prometheus_alertmanager_config: + - scheme: https + path_prefix: /alertmanager + basic_auth: + username: user + password: pass + static_configs: + - targets: ["127.0.0.1:9090"] + proxy_url: "127.0.0.2" + prometheus_alert_relabel_configs: + - action: labeldrop + regex: replica + prometheus_global: + scrape_interval: 3s + scrape_timeout: 2s + evaluation_interval: 10s + prometheus_remote_write: + - url: http://influx.cloudalchemy.org:8086/api/v1/prom/write?db=test + basic_auth: + username: prometheus + password: SuperSecret + prometheus_remote_read: + - url: http://influx.cloudalchemy.org:8086/api/v1/prom/read?db=cloudalchemy + prometheus_external_labels: + environment: "alternative" + prometheus_targets: + node: + - targets: + - demo.cloudalchemy.org:9100 + - influx.cloudalchemy.org:9100 + labels: + env: cloudalchemy + docker: + - targets: + - demo.cloudalchemy.org:8080 + - influx.cloudalchemy.org:8080 + labels: + env: cloudalchemy + prometheus_scrape_configs: + - job_name: "prometheus" + metrics_path: "{{ prometheus_metrics_path }}" + static_configs: + - targets: + - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" + - job_name: "node" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/node.yml" + - job_name: "docker" + file_sd_configs: + - files: + - "{{ prometheus_config_dir }}/file_sd/docker.yml" + - job_name: 'blackbox' + metrics_path: /probe + params: + module: [http_2xx] + static_configs: + - targets: + - http://demo.cloudalchemy.org:9100 + - http://influx.cloudalchemy.org:9100 + 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 # Blackbox exporter. diff --git a/roles/prometheus/molecule/alternative/prepare.yml b/roles/prometheus/molecule/alternative/prepare.yml new file mode 100644 index 00000000..41962804 --- /dev/null +++ b/roles/prometheus/molecule/alternative/prepare.yml @@ -0,0 +1,37 @@ +--- +- name: Prepare + hosts: localhost + gather_facts: false + vars: + # Version seeds to be specified here as molecule doesn't have access to ansible_version at this stage + version: 2.14.0 + tasks: + - name: download prometheus binary to local folder + become: false + get_url: + url: "https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz" + dest: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" + register: _download_archive + until: _download_archive is succeeded + retries: 5 + delay: 2 + run_once: true + check_mode: false + + - name: unpack prometheus binaries + become: false + unarchive: + src: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" + dest: "/tmp" + creates: "/tmp/prometheus-{{ version }}.linux-amd64/prometheus" + run_once: true + check_mode: false + + - name: link to prometheus binaries directory + become: false + file: + src: "/tmp/prometheus-{{ version }}.linux-amd64" + dest: "/tmp/prometheus-linux-amd64" + state: link + run_once: true + check_mode: false diff --git a/roles/prometheus/molecule/alternative/tests/test_alternative.py b/roles/prometheus/molecule/alternative/tests/test_alternative.py new file mode 100644 index 00000000..8ef6d2ad --- /dev/null +++ b/roles/prometheus/molecule/alternative/tests/test_alternative.py @@ -0,0 +1,44 @@ +import pytest +import os +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("dirs", [ + "/opt/prom/etc", + "/opt/prom/etc/rules", + "/opt/prom/etc/file_sd", + "/opt/prom/lib" +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/opt/prom/etc/prometheus.yml", + "/opt/prom/etc/rules/ansible_managed.rules", + "/opt/prom/etc/file_sd/node.yml", + "/opt/prom/etc/file_sd/docker.yml", + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://127.0.0.1:9090") + assert s.is_listening diff --git a/roles/prometheus/molecule/default/molecule.yml b/roles/prometheus/molecule/default/molecule.yml new file mode 100644 index 00000000..8937ee83 --- /dev/null +++ b/roles/prometheus/molecule/default/molecule.yml @@ -0,0 +1,75 @@ +--- +dependency: + name: galaxy +driver: + name: docker +# lint: | +# set -e +# yamllint . +# ansible-lint +# flake8 +platforms: + - name: bionic + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: xenial + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: stretch + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-9 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos7 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-7 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: centos8 + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:centos-8 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: playbook.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/default/playbook.yml b/roles/prometheus/molecule/default/playbook.yml new file mode 100644 index 00000000..688fb1dc --- /dev/null +++ b/roles/prometheus/molecule/default/playbook.yml @@ -0,0 +1,6 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus diff --git a/roles/prometheus/molecule/default/prepare.yml b/roles/prometheus/molecule/default/prepare.yml new file mode 100644 index 00000000..5358b3bd --- /dev/null +++ b/roles/prometheus/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/roles/prometheus/molecule/default/tests/test_default.py b/roles/prometheus/molecule/default/tests/test_default.py new file mode 100644 index 00000000..318d4fd7 --- /dev/null +++ b/roles/prometheus/molecule/default/tests/test_default.py @@ -0,0 +1,71 @@ +import pytest +import os +import yaml +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.fixture() +def AnsibleDefaults(): + with open("defaults/main.yml", 'r') as stream: + return yaml.load(stream) + + +@pytest.mark.parametrize("dirs", [ + "/etc/prometheus", + "/etc/prometheus/console_libraries", + "/etc/prometheus/consoles", + "/etc/prometheus/rules", + "/etc/prometheus/file_sd", + "/var/lib/prometheus" +]) +def test_directories(host, dirs): + d = host.file(dirs) + assert d.is_directory + assert d.exists + + +@pytest.mark.parametrize("files", [ + "/etc/prometheus/prometheus.yml", + "/etc/prometheus/console_libraries/prom.lib", + "/etc/prometheus/consoles/prometheus.html", + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +@pytest.mark.parametrize("files", [ + "/etc/prometheus/rules/ansible_managed.rules" +]) +def test_absent(host, files): + f = host.file(files) + assert f.exists + + +def test_user(host): + assert host.group("prometheus").exists + assert host.user("prometheus").exists + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://0.0.0.0:9090") + assert s.is_listening + + +def test_version(host, AnsibleDefaults): + version = os.getenv('PROMETHEUS', AnsibleDefaults['prometheus_version']) + out = host.run("/usr/local/bin/prometheus --version").stderr + assert "prometheus, version " + version in out diff --git a/roles/prometheus/molecule/latest/molecule.yml b/roles/prometheus/molecule/latest/molecule.yml new file mode 100644 index 00000000..a5a9cebb --- /dev/null +++ b/roles/prometheus/molecule/latest/molecule.yml @@ -0,0 +1,35 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: buster + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:debian-10 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + - name: fedora + pre_build_image: true + image: quay.io/paulfantom/molecule-systemd:fedora-30 + docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + groups: + - python3 +provisioner: + name: ansible + playbooks: + create: ../default/create.yml + prepare: ../default/prepare.yml + converge: playbook.yml + destroy: ../default/destroy.yml + inventory: + group_vars: + python3: + ansible_python_interpreter: /usr/bin/python3 +verifier: + name: testinfra diff --git a/roles/prometheus/molecule/latest/playbook.yml b/roles/prometheus/molecule/latest/playbook.yml new file mode 100644 index 00000000..9a7cc711 --- /dev/null +++ b/roles/prometheus/molecule/latest/playbook.yml @@ -0,0 +1,8 @@ +--- +- name: Run role + hosts: all + any_errors_fatal: true + roles: + - ansible-prometheus + vars: + prometheus_version: latest diff --git a/roles/prometheus/molecule/latest/tests/test_alternative.py b/roles/prometheus/molecule/latest/tests/test_alternative.py new file mode 100644 index 00000000..cbefab91 --- /dev/null +++ b/roles/prometheus/molecule/latest/tests/test_alternative.py @@ -0,0 +1,28 @@ +import pytest +import os +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +@pytest.mark.parametrize("files", [ + "/etc/systemd/system/prometheus.service", + "/usr/local/bin/prometheus", + "/usr/local/bin/promtool" +]) +def test_files(host, files): + f = host.file(files) + assert f.exists + assert f.is_file + + +def test_service(host): + s = host.service("prometheus") + # assert s.is_enabled + assert s.is_running + + +def test_socket(host): + s = host.socket("tcp://0.0.0.0:9090") + assert s.is_listening diff --git a/roles/prometheus/tasks/configure.yml b/roles/prometheus/tasks/configure.yml new file mode 100644 index 00000000..8c76d332 --- /dev/null +++ b/roles/prometheus/tasks/configure.yml @@ -0,0 +1,60 @@ +--- +- name: alerting rules file + template: + src: "alert.rules.j2" + dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules" + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" + when: + - prometheus_alert_rules != [] + notify: + - reload prometheus + +- name: copy custom alerting rule files + copy: + src: "{{ item }}" + dest: "{{ prometheus_config_dir }}/rules/" + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" + with_fileglob: "{{ prometheus_alert_rules_files }}" + notify: + - reload prometheus + +- name: configure prometheus + template: + src: "{{ prometheus_config_file }}" + dest: "{{ prometheus_config_dir }}/prometheus.yml" + force: true + owner: root + group: prometheus + mode: 0640 + validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s" + notify: + - reload prometheus + +- name: configure prometheus static targets + copy: + content: | + #jinja2: lstrip_blocks: True + {{ item.value | to_nice_yaml(indent=2) }} + dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml" + force: true + owner: root + group: prometheus + mode: 0640 + with_dict: "{{ prometheus_targets }}" + when: prometheus_targets != {} + +- name: copy prometheus custom static targets + copy: + src: "{{ item }}" + dest: "{{ prometheus_config_dir }}/file_sd/" + force: true + owner: root + group: prometheus + mode: 0640 + with_fileglob: "{{ prometheus_static_targets_files }}" diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml new file mode 100644 index 00000000..e473d848 --- /dev/null +++ b/roles/prometheus/tasks/install.yml @@ -0,0 +1,137 @@ +--- +- name: create prometheus system group + group: + name: prometheus + system: true + state: present + +- name: create prometheus system user + user: + name: prometheus + system: true + shell: "/usr/sbin/nologin" + group: prometheus + createhome: false + home: "{{ prometheus_db_dir }}" + +- name: create prometheus data directory + file: + path: "{{ prometheus_db_dir }}" + state: directory + owner: prometheus + group: prometheus + mode: 0755 + +- name: create prometheus configuration directories + file: + path: "{{ item }}" + state: directory + owner: root + group: prometheus + mode: 0770 + with_items: + - "{{ prometheus_config_dir }}" + - "{{ prometheus_config_dir }}/rules" + - "{{ prometheus_config_dir }}/file_sd" + +- block: + - name: download prometheus binary to local folder + become: false + get_url: + url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + checksum: "sha256:{{ __prometheus_checksum }}" + register: _download_archive + until: _download_archive is succeeded + retries: 5 + delay: 2 + # run_once: true # <-- this cannot be set due to multi-arch support + delegate_to: localhost + check_mode: false + + - name: unpack prometheus binaries + become: false + unarchive: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" + dest: "/tmp" + creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/prometheus" + delegate_to: localhost + check_mode: false + + - name: propagate official prometheus and promtool binaries + copy: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}" + dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" + mode: 0755 + owner: root + group: root + with_items: + - prometheus + - promtool + notify: + - restart prometheus + + - name: propagate official console templates + copy: + src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}/" + dest: "{{ prometheus_config_dir }}/{{ item }}/" + mode: 0644 + owner: root + group: root + with_items: + - console_libraries + - consoles + notify: + - restart prometheus + when: + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install + +- name: propagate locally distributed prometheus and promtool binaries + copy: + src: "{{ prometheus_binary_local_dir }}/{{ item }}" + dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" + mode: 0755 + owner: root + group: root + with_items: + - prometheus + - promtool + when: + - prometheus_binary_local_dir | length > 0 + - not prometheus_skip_install + notify: + - restart prometheus + +- name: create systemd service unit + template: + src: prometheus.service.j2 + dest: /etc/systemd/system/prometheus.service + owner: root + group: root + mode: 0644 + notify: + - restart prometheus + +- name: Install SELinux dependencies + package: + name: "{{ item }}" + state: present + with_items: "{{ prometheus_selinux_packages }}" + register: _install_packages + until: _install_packages is succeeded + retries: 5 + delay: 2 + when: + - ansible_version.full is version('2.4', '>=') + - ansible_selinux.status == "enabled" + +- name: Allow prometheus to bind to port in SELinux + seport: + ports: "{{ prometheus_web_listen_address.split(':')[1] }}" + proto: tcp + setype: http_port_t + state: present + when: + - ansible_version.full is version('2.4', '>=') + - ansible_selinux.status == "enabled" diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml new file mode 100644 index 00000000..ec32a72c --- /dev/null +++ b/roles/prometheus/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - prometheus_configure + - prometheus_install + - prometheus_run + +- include: preflight.yml + tags: + - prometheus_configure + - prometheus_install + - prometheus_run + +- include: install.yml + become: true + tags: + - prometheus_install + +- include: configure.yml + become: true + tags: + - prometheus_configure + +- name: ensure prometheus service is started and enabled + become: true + systemd: + daemon_reload: true + name: prometheus + state: started + enabled: true + tags: + - prometheus_run diff --git a/roles/prometheus/tasks/preflight.yml b/roles/prometheus/tasks/preflight.yml new file mode 100644 index 00000000..1582f8ac --- /dev/null +++ b/roles/prometheus/tasks/preflight.yml @@ -0,0 +1,114 @@ +--- +- name: Assert usage of systemd as an init system + assert: + that: ansible_service_mgr == 'systemd' + msg: "This module only works with systemd" + +- name: Get systemd version + command: systemctl --version + changed_when: false + check_mode: false + register: __systemd_version + tags: + - skip_ansible_lint + +- name: Set systemd version fact + set_fact: + prometheus_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}" + +- name: Assert no duplicate config flags + assert: + that: + - prometheus_config_flags_extra['config.file'] is not defined + - prometheus_config_flags_extra['storage.tsdb.path'] is not defined + - prometheus_config_flags_extra['storage.local.path'] is not defined + - prometheus_config_flags_extra['web.listen-address'] is not defined + - prometheus_config_flags_extra['web.external-url'] is not defined + msg: "Detected duplicate configuration entry. Please check your ansible variables and role README.md." + +- name: Assert external_labels aren't configured twice + assert: + that: prometheus_global.external_labels is not defined + msg: "Use prometheus_external_labels to define external labels" + +- name: Set prometheus external metrics path + set_fact: + prometheus_metrics_path: "/{{ ( prometheus_web_external_url + '/metrics' ) | regex_replace('^(.*://)?(.*?)/') }}" + +- name: Fail when prometheus_config_flags_extra duplicates parameters set by other variables + fail: + msg: > + Whooops. You are duplicating configuration. Please look at your prometheus_config_flags_extra + and check against other variables in defaults/main.yml + with_items: + - 'storage.tsdb.retention' + - 'storage.tsdb.path' + - 'storage.local.retention' + - 'storage.local.path' + - 'config.file' + - 'web.listen-address' + - 'web.external-url' + when: item in prometheus_config_flags_extra.keys() + +- name: Get all file_sd files from scrape_configs + set_fact: + file_sd_files: "{{ prometheus_scrape_configs | json_query('[*][].file_sd_configs[*][].files[]') }}" + +- name: Fail when file_sd targets are not defined in scrape_configs + fail: + msg: > + Oh, snap! `{{ item.key }}` couldn't be found in your scrape configs. Please ensure you provided + all targets from prometheus_targets in prometheus_scrape_configs + when: not prometheus_config_dir + "/file_sd/" + item.key + ".yml" in file_sd_files + # when: not item | basename | splitext | difference(['.yml']) | join('') in prometheus_targets.keys() + with_dict: "{{ prometheus_targets }}" + +- name: Alert when prometheus_alertmanager_config is empty, but prometheus_alert_rules is specified + debug: + msg: > + No alertmanager configuration was specified. If you want your alerts to be sent make sure to + specify a prometheus_alertmanager_config in defaults/main.yml. + when: + - prometheus_alertmanager_config == [] + - prometheus_alert_rules != [] + +- block: + - name: Get latest release + uri: + url: "https://api.github.com/repos/prometheus/prometheus/releases/latest" + method: GET + return_content: true + status_code: 200 + body_format: json + validate_certs: false + user: "{{ lookup('env', 'GH_USER') | default(omit) }}" + password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}" + no_log: "{{ not lookup('env', 'ANSIBLE_DEBUG') | bool }}" + register: _latest_release + until: _latest_release.status == 200 + retries: 5 + + - name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}" + set_fact: + prometheus_version: "{{ _latest_release.json.tag_name[1:] }}" + when: + - prometheus_version == "latest" + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install + +- block: + - name: "Get checksum list" + set_fact: + __prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', wantlist=True) | list }}" + run_once: true + + - name: "Get checksum for {{ go_arch }} architecture" + set_fact: + __prometheus_checksum: "{{ item.split(' ')[0] }}" + with_items: "{{ __prometheus_checksums }}" + when: + - "('linux-' + go_arch + '.tar.gz') in item" + delegate_to: localhost + when: + - prometheus_binary_local_dir | length == 0 + - not prometheus_skip_install diff --git a/roles/prometheus/templates/alert.rules.j2 b/roles/prometheus/templates/alert.rules.j2 new file mode 100644 index 00000000..8498cf85 --- /dev/null +++ b/roles/prometheus/templates/alert.rules.j2 @@ -0,0 +1,6 @@ +{{ ansible_managed | comment }} + +groups: +- name: ansible managed alert rules + rules: + {{ prometheus_alert_rules | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/templates/prometheus.service.j2 b/roles/prometheus/templates/prometheus.service.j2 new file mode 100644 index 00000000..0348b9fe --- /dev/null +++ b/roles/prometheus/templates/prometheus.service.j2 @@ -0,0 +1,66 @@ +{{ ansible_managed | comment }} + +[Unit] +Description=Prometheus +After=network-online.target +Requires=local-fs.target +After=local-fs.target + +[Service] +Type=simple +Environment="GOMAXPROCS={{ ansible_processor_vcpus|default(ansible_processor_count) }}" +User=prometheus +Group=prometheus +ExecReload=/bin/kill -HUP $MAINPID +ExecStart={{ _prometheus_binary_install_dir }}/prometheus \ + --config.file={{ prometheus_config_dir }}/prometheus.yml \ + --storage.tsdb.path={{ prometheus_db_dir }} \ +{% if prometheus_version is version('2.7.0', '>=') %} + --storage.tsdb.retention.time={{ prometheus_storage_retention }} \ + --storage.tsdb.retention.size={{ prometheus_storage_retention_size }} \ +{% else %} + --storage.tsdb.retention={{ prometheus_storage_retention }} \ +{% endif %} + --web.console.libraries={{ prometheus_config_dir }}/console_libraries \ + --web.console.templates={{ prometheus_config_dir }}/consoles \ + --web.listen-address={{ prometheus_web_listen_address }} \ + --web.external-url={{ prometheus_web_external_url }}{% for flag, flag_value in prometheus_config_flags_extra.items() %}\ + --{{ flag }}{% if flag_value %}={{ flag_value }}{% endif %} {% endfor %} + +CapabilityBoundingSet=CAP_SET_UID +LimitNOFILE=65000 +LockPersonality=true +NoNewPrivileges=true +MemoryDenyWriteExecute=true +PrivateDevices=true +PrivateTmp=true +ProtectHome=true +RemoveIPC=true +RestrictSUIDSGID=true +#SystemCallFilter=@signal @timer + +{% if prometheus_systemd_version | int >= 231 %} +ReadWritePaths={{ prometheus_db_dir }} +{% else %} +ReadWriteDirectories={{ prometheus_db_dir }} +{% endif %} + +{% if prometheus_systemd_version | int >= 232 %} +PrivateUsers=true +ProtectControlGroups=true +ProtectKernelModules=true +ProtectKernelTunables=true +ProtectSystem=strict +{% else %} +ProtectSystem=full +{% endif %} + +{% if http_proxy is defined %} +Environment="HTTP_PROXY={{ http_proxy }}"{% if https_proxy is defined %} "HTTPS_PROXY={{ https_proxy }}{% endif %}" +{% endif %} + +SyslogIdentifier=prometheus +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 new file mode 100644 index 00000000..d16a1843 --- /dev/null +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,34 @@ +#jinja2: trim_blocks: True, lstrip_blocks: True +{{ ansible_managed | comment }} +# http://prometheus.io/docs/operating/configuration/ + +global: + {{ prometheus_global | to_nice_yaml(indent=2) | indent(2, False) }} + external_labels: + {{ prometheus_external_labels | to_nice_yaml(indent=2) | indent(4, False) }} + +{% if prometheus_remote_write != [] %} +remote_write: + {{ prometheus_remote_write | to_nice_yaml(indent=2) | indent(2, False) }} +{% endif %} + +{% if prometheus_remote_read != [] %} +remote_read: + {{ prometheus_remote_read | to_nice_yaml(indent=2) | indent(2, False) }} +{% endif %} + +rule_files: + - {{ prometheus_config_dir }}/rules/*.rules + +{% if prometheus_alertmanager_config | length > 0 %} +alerting: + alertmanagers: + {{ prometheus_alertmanager_config | to_nice_yaml(indent=2) | indent(2,False) }} + {% if prometheus_alert_relabel_configs | length > 0 %} + alert_relabel_configs: + {{ prometheus_alert_relabel_configs | to_nice_yaml(indent=2) | indent(2,False) }} + {% endif %} +{% endif %} + +scrape_configs: + {{ prometheus_scrape_configs | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/test-requirements.txt b/roles/prometheus/test-requirements.txt new file mode 100644 index 00000000..1b6e9a96 --- /dev/null +++ b/roles/prometheus/test-requirements.txt @@ -0,0 +1,8 @@ +molecule>=3.0.0 +molecule-docker +docker +ansible-lint>=3.4.0 +testinfra>=1.7.0 +jmespath +selinux +passlib diff --git a/roles/prometheus/vars/centos-8.yml b/roles/prometheus/vars/centos-8.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/centos-8.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/centos.yml b/roles/prometheus/vars/centos.yml new file mode 100644 index 00000000..ea3dea19 --- /dev/null +++ b/roles/prometheus/vars/centos.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - libselinux-python + - policycoreutils-python diff --git a/roles/prometheus/vars/debian.yml b/roles/prometheus/vars/debian.yml new file mode 100644 index 00000000..d109c39f --- /dev/null +++ b/roles/prometheus/vars/debian.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python-selinux + - policycoreutils diff --git a/roles/prometheus/vars/fedora.yml b/roles/prometheus/vars/fedora.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/fedora.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/main.yml b/roles/prometheus/vars/main.yml new file mode 100644 index 00000000..091379fd --- /dev/null +++ b/roles/prometheus/vars/main.yml @@ -0,0 +1,10 @@ +--- +go_arch_map: + i386: '386' + x86_64: 'amd64' + aarch64: 'arm64' + armv7l: 'armv7' + armv6l: 'armv6' + +go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" +_prometheus_binary_install_dir: '/usr/local/bin' diff --git a/roles/prometheus/vars/redhat-8.yml b/roles/prometheus/vars/redhat-8.yml new file mode 100644 index 00000000..3fc18d81 --- /dev/null +++ b/roles/prometheus/vars/redhat-8.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - python3-libselinux + - python3-policycoreutils diff --git a/roles/prometheus/vars/redhat.yml b/roles/prometheus/vars/redhat.yml new file mode 100644 index 00000000..ea3dea19 --- /dev/null +++ b/roles/prometheus/vars/redhat.yml @@ -0,0 +1,4 @@ +--- +prometheus_selinux_packages: + - libselinux-python + - policycoreutils-python From 51083068fe2e1448f9279ceecde986c9b4e302e4 Mon Sep 17 00:00:00 2001 From: tingwei Date: Thu, 7 Nov 2024 18:13:34 +0800 Subject: [PATCH 2/4] use safe load --- roles/prometheus/molecule/default/tests/test_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/prometheus/molecule/default/tests/test_default.py b/roles/prometheus/molecule/default/tests/test_default.py index 318d4fd7..3a2e5b48 100644 --- a/roles/prometheus/molecule/default/tests/test_default.py +++ b/roles/prometheus/molecule/default/tests/test_default.py @@ -10,7 +10,7 @@ @pytest.fixture() def AnsibleDefaults(): with open("defaults/main.yml", 'r') as stream: - return yaml.load(stream) + return yaml.safe_load(stream) @pytest.mark.parametrize("dirs", [ From 66e5be9ab1c6cd6ab37f5dfd847c977f71a6d450 Mon Sep 17 00:00:00 2001 From: tingwei Date: Fri, 8 Nov 2024 16:21:41 +0800 Subject: [PATCH 3/4] remove prometheus --- roles/prometheus/.ansible-lint | 5 - roles/prometheus/.gitignore | 7 - roles/prometheus/.mergify.yml | 12 - roles/prometheus/.yamllint | 14 - roles/prometheus/CHANGELOG.md | 782 ------------------ roles/prometheus/CONTRIBUTING.md | 97 --- roles/prometheus/LICENSE | 21 - roles/prometheus/README.md | 156 ---- roles/prometheus/TROUBLESHOOTING.md | 3 - roles/prometheus/defaults/main.yml | 213 ----- roles/prometheus/handlers/main.yml | 13 - roles/prometheus/meta/main.yml | 34 - .../molecule/alternative/molecule.yml | 70 -- .../molecule/alternative/playbook.yml | 84 -- .../molecule/alternative/prepare.yml | 37 - .../alternative/tests/test_alternative.py | 44 - .../prometheus/molecule/default/molecule.yml | 75 -- .../prometheus/molecule/default/playbook.yml | 6 - roles/prometheus/molecule/default/prepare.yml | 5 - .../molecule/default/tests/test_default.py | 71 -- roles/prometheus/molecule/latest/molecule.yml | 35 - roles/prometheus/molecule/latest/playbook.yml | 8 - .../molecule/latest/tests/test_alternative.py | 28 - roles/prometheus/tasks/configure.yml | 60 -- roles/prometheus/tasks/install.yml | 137 --- roles/prometheus/tasks/main.yml | 37 - roles/prometheus/tasks/preflight.yml | 114 --- roles/prometheus/templates/alert.rules.j2 | 6 - .../templates/prometheus.service.j2 | 66 -- roles/prometheus/templates/prometheus.yml.j2 | 34 - roles/prometheus/test-requirements.txt | 8 - roles/prometheus/vars/centos-8.yml | 4 - roles/prometheus/vars/centos.yml | 4 - roles/prometheus/vars/debian.yml | 4 - roles/prometheus/vars/fedora.yml | 4 - roles/prometheus/vars/main.yml | 10 - roles/prometheus/vars/redhat-8.yml | 4 - roles/prometheus/vars/redhat.yml | 4 - 38 files changed, 2316 deletions(-) delete mode 100644 roles/prometheus/.ansible-lint delete mode 100644 roles/prometheus/.gitignore delete mode 100644 roles/prometheus/.mergify.yml delete mode 100644 roles/prometheus/.yamllint delete mode 100644 roles/prometheus/CHANGELOG.md delete mode 100644 roles/prometheus/CONTRIBUTING.md delete mode 100644 roles/prometheus/LICENSE delete mode 100644 roles/prometheus/README.md delete mode 100644 roles/prometheus/TROUBLESHOOTING.md delete mode 100644 roles/prometheus/defaults/main.yml delete mode 100644 roles/prometheus/handlers/main.yml delete mode 100644 roles/prometheus/meta/main.yml delete mode 100644 roles/prometheus/molecule/alternative/molecule.yml delete mode 100644 roles/prometheus/molecule/alternative/playbook.yml delete mode 100644 roles/prometheus/molecule/alternative/prepare.yml delete mode 100644 roles/prometheus/molecule/alternative/tests/test_alternative.py delete mode 100644 roles/prometheus/molecule/default/molecule.yml delete mode 100644 roles/prometheus/molecule/default/playbook.yml delete mode 100644 roles/prometheus/molecule/default/prepare.yml delete mode 100644 roles/prometheus/molecule/default/tests/test_default.py delete mode 100644 roles/prometheus/molecule/latest/molecule.yml delete mode 100644 roles/prometheus/molecule/latest/playbook.yml delete mode 100644 roles/prometheus/molecule/latest/tests/test_alternative.py delete mode 100644 roles/prometheus/tasks/configure.yml delete mode 100644 roles/prometheus/tasks/install.yml delete mode 100644 roles/prometheus/tasks/main.yml delete mode 100644 roles/prometheus/tasks/preflight.yml delete mode 100644 roles/prometheus/templates/alert.rules.j2 delete mode 100644 roles/prometheus/templates/prometheus.service.j2 delete mode 100644 roles/prometheus/templates/prometheus.yml.j2 delete mode 100644 roles/prometheus/test-requirements.txt delete mode 100644 roles/prometheus/vars/centos-8.yml delete mode 100644 roles/prometheus/vars/centos.yml delete mode 100644 roles/prometheus/vars/debian.yml delete mode 100644 roles/prometheus/vars/fedora.yml delete mode 100644 roles/prometheus/vars/main.yml delete mode 100644 roles/prometheus/vars/redhat-8.yml delete mode 100644 roles/prometheus/vars/redhat.yml diff --git a/roles/prometheus/.ansible-lint b/roles/prometheus/.ansible-lint deleted file mode 100644 index ad9fc9f9..00000000 --- a/roles/prometheus/.ansible-lint +++ /dev/null @@ -1,5 +0,0 @@ ---- -skip_list: -- '106' -- '204' -- '208' diff --git a/roles/prometheus/.gitignore b/roles/prometheus/.gitignore deleted file mode 100644 index db70ede3..00000000 --- a/roles/prometheus/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.retry -*.log -.molecule -.cache -__pycache__/ -.pytest_cache -.tox diff --git a/roles/prometheus/.mergify.yml b/roles/prometheus/.mergify.yml deleted file mode 100644 index 877a4825..00000000 --- a/roles/prometheus/.mergify.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -pull_request_rules: - - name: automatic merge and new release from cloudalchemybot - conditions: - - "status-success=Travis CI - Pull Request" - - status-success=WIP - - head~=autoupdate|skeleton - - author=cloudalchemybot - actions: - merge: - method: squash - strict: true diff --git a/roles/prometheus/.yamllint b/roles/prometheus/.yamllint deleted file mode 100644 index 8f2e1fa2..00000000 --- a/roles/prometheus/.yamllint +++ /dev/null @@ -1,14 +0,0 @@ ---- -extends: default -ignore: | - .github/ - meta/ - -rules: - braces: - max-spaces-inside: 1 - level: error - brackets: - max-spaces-inside: 1 - level: error - line-length: disable diff --git a/roles/prometheus/CHANGELOG.md b/roles/prometheus/CHANGELOG.md deleted file mode 100644 index e55a25b4..00000000 --- a/roles/prometheus/CHANGELOG.md +++ /dev/null @@ -1,782 +0,0 @@ -# Change Log - -## [**Next release**](https://galaxy.ansible.com/cloudalchemy/prometheus) - -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#318](https://github.com/cloudalchemy/ansible-prometheus/pull/318) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.16.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-11-04) -**Merged pull requests:** - -- Wait for local file systems before starting prometheus [\#317](https://github.com/cloudalchemy/ansible-prometheus/pull/317) ([bartoszcisek](https://github.com/bartoszcisek)) - -## [2.16.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-10-20) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#316](https://github.com/cloudalchemy/ansible-prometheus/pull/316) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.16.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-09-28) -**Implemented enhancements:** - -- offline support [\#296](https://github.com/cloudalchemy/ansible-prometheus/issues/296) - -**Fixed bugs:** - -- prometheus\_scrape\_configs changes line order [\#310](https://github.com/cloudalchemy/ansible-prometheus/issues/310) -- conf.d folder is provided, but there is no mechanism for using it [\#283](https://github.com/cloudalchemy/ansible-prometheus/issues/283) - -**Closed issues:** - -- You need to install \"jmespath\" prior to running json\_query filter [\#314](https://github.com/cloudalchemy/ansible-prometheus/issues/314) - -**Merged pull requests:** - -- Bump version [\#315](https://github.com/cloudalchemy/ansible-prometheus/pull/315) ([SuperQ](https://github.com/SuperQ)) -- \[REPO SYNC\] add troubleshooting doc skeleton [\#309](https://github.com/cloudalchemy/ansible-prometheus/pull/309) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus/prometheus upstream release! [\#303](https://github.com/cloudalchemy/ansible-prometheus/pull/303) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Do not create unused directory conf.d [\#299](https://github.com/cloudalchemy/ansible-prometheus/pull/299) ([paulfantom](https://github.com/paulfantom)) -- New prometheus/prometheus upstream release! [\#298](https://github.com/cloudalchemy/ansible-prometheus/pull/298) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.15.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-06-09) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#293](https://github.com/cloudalchemy/ansible-prometheus/pull/293) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] Add passlib as a test requirement [\#292](https://github.com/cloudalchemy/ansible-prometheus/pull/292) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.15.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-09) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#290](https://github.com/cloudalchemy/ansible-prometheus/pull/290) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.15.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-05-07) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#289](https://github.com/cloudalchemy/ansible-prometheus/pull/289) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- improve path\_prefix example in defaults [\#266](https://github.com/cloudalchemy/ansible-prometheus/pull/266) ([zxyz](https://github.com/zxyz)) - -## [2.15.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-20) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#284](https://github.com/cloudalchemy/ansible-prometheus/pull/284) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.15.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-14) -**Merged pull requests:** - -- Fix version\_compare filter deprecation [\#282](https://github.com/cloudalchemy/ansible-prometheus/pull/282) ([ecksun](https://github.com/ecksun)) - -## [2.15.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-04-12) -**Fixed bugs:** - -- Readme variable prometheus\_binaries\_local\_dir [\#279](https://github.com/cloudalchemy/ansible-prometheus/issues/279) - -**Merged pull requests:** - -- Update Readme variable prometheus\_binary\_local\_dir [\#280](https://github.com/cloudalchemy/ansible-prometheus/pull/280) ([asatblurbs](https://github.com/asatblurbs)) -- added installation method config to skip install [\#272](https://github.com/cloudalchemy/ansible-prometheus/pull/272) ([DEvil0000](https://github.com/DEvil0000)) - -## [2.14.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-27) -**Fixed bugs:** - -- CriticalDiskSpace Alert using wrong Metrics [\#275](https://github.com/cloudalchemy/ansible-prometheus/issues/275) - -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#277](https://github.com/cloudalchemy/ansible-prometheus/pull/277) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- defaults: sync alerts from node-mixin project [\#276](https://github.com/cloudalchemy/ansible-prometheus/pull/276) ([paulfantom](https://github.com/paulfantom)) - -## [2.14.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-25) -**Merged pull requests:** - -- Upstream release update [\#274](https://github.com/cloudalchemy/ansible-prometheus/pull/274) ([paulfantom](https://github.com/paulfantom)) - -## [2.14.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-03-15) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#265](https://github.com/cloudalchemy/ansible-prometheus/pull/265) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Do not manage system directory [\#263](https://github.com/cloudalchemy/ansible-prometheus/pull/263) ([paulfantom](https://github.com/paulfantom)) -- Add binary install directory [\#259](https://github.com/cloudalchemy/ansible-prometheus/pull/259) ([guimaluf](https://github.com/guimaluf)) - -## [2.13.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-20) -**Merged pull requests:** - -- \[REPO SYNC\] Merge pull request \#4 from cloudalchemy/travis\_fix [\#260](https://github.com/cloudalchemy/ansible-prometheus/pull/260) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Improve checksum fetching [\#254](https://github.com/cloudalchemy/ansible-prometheus/pull/254) ([SuperQ](https://github.com/SuperQ)) - -## [2.13.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-11) -**Fixed bugs:** - -- prometheus\_version: latest =\> failed to get sha256sums.txt [\#230](https://github.com/cloudalchemy/ansible-prometheus/issues/230) - -**Merged pull requests:** - -- Switch user login shell to /usr/sbin/nologin [\#258](https://github.com/cloudalchemy/ansible-prometheus/pull/258) ([paulfantom](https://github.com/paulfantom)) - -## [2.13.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2020-01-08) -**Closed issues:** - -- Use python3-libselinux instead of libselinux-python on RHEL8/CentOS8 [\#244](https://github.com/cloudalchemy/ansible-prometheus/issues/244) - -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#256](https://github.com/cloudalchemy/ansible-prometheus/pull/256) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] use latest available python [\#255](https://github.com/cloudalchemy/ansible-prometheus/pull/255) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus/prometheus upstream release! [\#253](https://github.com/cloudalchemy/ansible-prometheus/pull/253) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus/prometheus upstream release! [\#252](https://github.com/cloudalchemy/ansible-prometheus/pull/252) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] remove IRC link [\#251](https://github.com/cloudalchemy/ansible-prometheus/pull/251) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Fix typo [\#249](https://github.com/cloudalchemy/ansible-prometheus/pull/249) ([Mehonoshin](https://github.com/Mehonoshin)) -- Add CentOS/CentOS-8 support [\#248](https://github.com/cloudalchemy/ansible-prometheus/pull/248) ([ggatward](https://github.com/ggatward)) -- \[REPO SYNC\] add declarative label sync; add autolabelling PRs [\#243](https://github.com/cloudalchemy/ansible-prometheus/pull/243) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] molecule: use CI images from quay.io instead of dockerhub [\#241](https://github.com/cloudalchemy/ansible-prometheus/pull/241) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- add option to propagate binaries without access to internet [\#239](https://github.com/cloudalchemy/ansible-prometheus/pull/239) ([paulfantom](https://github.com/paulfantom)) - -## [2.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-11-13) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#240](https://github.com/cloudalchemy/ansible-prometheus/pull/240) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] Update releaser.sh [\#236](https://github.com/cloudalchemy/ansible-prometheus/pull/236) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- \[REPO SYNC\] add support for CentOS8 [\#233](https://github.com/cloudalchemy/ansible-prometheus/pull/233) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus/prometheus upstream release! [\#232](https://github.com/cloudalchemy/ansible-prometheus/pull/232) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-10-05) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#231](https://github.com/cloudalchemy/ansible-prometheus/pull/231) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Synchronize files from cloudalchemy/skeleton [\#227](https://github.com/cloudalchemy/ansible-prometheus/pull/227) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- add RHEL8 and debian buster support; remove testing on debian jessie [\#226](https://github.com/cloudalchemy/ansible-prometheus/pull/226) ([paulfantom](https://github.com/paulfantom)) -- Some "false" were incorrectly substituted to "no" [\#225](https://github.com/cloudalchemy/ansible-prometheus/pull/225) ([wzyboy](https://github.com/wzyboy)) -- Update minimum required ansible version [\#224](https://github.com/cloudalchemy/ansible-prometheus/pull/224) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Moving to python 3 and dropping support for python 2.x \(on deployer host\) [\#223](https://github.com/cloudalchemy/ansible-prometheus/pull/223) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-19) -**Implemented enhancements:** - -- Support recording rules without alerts [\#192](https://github.com/cloudalchemy/ansible-prometheus/issues/192) - -**Fixed bugs:** - -- Prometheus failed to start on Ubuntu 18.04: LimitNOFILE: Operation not permitted [\#190](https://github.com/cloudalchemy/ansible-prometheus/issues/190) - -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#221](https://github.com/cloudalchemy/ansible-prometheus/pull/221) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Synchronize files from cloudalchemy/skeleton [\#220](https://github.com/cloudalchemy/ansible-prometheus/pull/220) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Allow specifying recording rules without alerting configuration [\#212](https://github.com/cloudalchemy/ansible-prometheus/pull/212) ([paulfantom](https://github.com/paulfantom)) - -## [2.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-08-14) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#219](https://github.com/cloudalchemy/ansible-prometheus/pull/219) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus/prometheus upstream release! [\#217](https://github.com/cloudalchemy/ansible-prometheus/pull/217) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-07-11) -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#216](https://github.com/cloudalchemy/ansible-prometheus/pull/216) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-27) -**Closed issues:** - -- prometheus\_alert\_rules\_files link is broken [\#207](https://github.com/cloudalchemy/ansible-prometheus/issues/207) - -**Merged pull requests:** - -- New prometheus/prometheus upstream release! [\#209](https://github.com/cloudalchemy/ansible-prometheus/pull/209) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- add watchdog and clock skew alerts [\#206](https://github.com/cloudalchemy/ansible-prometheus/pull/206) ([paulfantom](https://github.com/paulfantom)) - -## [2.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-05-04) -**Fixed bugs:** - -- Default CriticalDiskSpace alert using wrong label? [\#201](https://github.com/cloudalchemy/ansible-prometheus/issues/201) - -**Merged pull requests:** - -- Synchronize files from cloudalchemy/skeleton [\#205](https://github.com/cloudalchemy/ansible-prometheus/pull/205) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Wait for network to be online [\#204](https://github.com/cloudalchemy/ansible-prometheus/pull/204) ([paulfantom](https://github.com/paulfantom)) -- New prometheus/prometheus upstream release! [\#203](https://github.com/cloudalchemy/ansible-prometheus/pull/203) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Update label for CriticalDiskSpace alert expression. [\#202](https://github.com/cloudalchemy/ansible-prometheus/pull/202) ([mjbnz](https://github.com/mjbnz)) -- New prometheus/prometheus upstream release! [\#200](https://github.com/cloudalchemy/ansible-prometheus/pull/200) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.8.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-30) -**Merged pull requests:** - -- set go\_arch as a var instead of calculating it during task execution [\#198](https://github.com/cloudalchemy/ansible-prometheus/pull/198) ([paulfantom](https://github.com/paulfantom)) -- New prometheus/prometheus upstream release! [\#197](https://github.com/cloudalchemy/ansible-prometheus/pull/197) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Synchronize files from cloudalchemy/skeleton. [\#196](https://github.com/cloudalchemy/ansible-prometheus/pull/196) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-23) -**Implemented enhancements:** - -- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) - -**Fixed bugs:** - -- Get more recognition! [\#131](https://github.com/cloudalchemy/ansible-prometheus/issues/131) - -**Closed issues:** - -- can't create prometheus user again [\#185](https://github.com/cloudalchemy/ansible-prometheus/issues/185) -- Implement Uninstalls based on specific variables [\#181](https://github.com/cloudalchemy/ansible-prometheus/issues/181) -- Allow Multiple blackbox exporters [\#179](https://github.com/cloudalchemy/ansible-prometheus/issues/179) -- Install prometheus using docker [\#173](https://github.com/cloudalchemy/ansible-prometheus/issues/173) - -**Merged pull requests:** - -- New prometheus upstream release! [\#193](https://github.com/cloudalchemy/ansible-prometheus/pull/193) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- prometheus.service.j2: stop using tests as filters [\#191](https://github.com/cloudalchemy/ansible-prometheus/pull/191) ([JordanP](https://github.com/JordanP)) -- Preflight checks refactor [\#189](https://github.com/cloudalchemy/ansible-prometheus/pull/189) ([paulfantom](https://github.com/paulfantom)) -- do not remove '/opt/prometheus' [\#188](https://github.com/cloudalchemy/ansible-prometheus/pull/188) ([paulfantom](https://github.com/paulfantom)) -- Parameterise custom static targets file paths [\#187](https://github.com/cloudalchemy/ansible-prometheus/pull/187) ([hamishforbes](https://github.com/hamishforbes)) -- Make prometheus user owner of prometheus folders [\#174](https://github.com/cloudalchemy/ansible-prometheus/pull/174) ([curantes](https://github.com/curantes)) - -## [2.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-03-04) -**Merged pull requests:** - -- New prometheus upstream release! [\#186](https://github.com/cloudalchemy/ansible-prometheus/pull/186) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Reworked prometheus\_alert\_rules\_files [\#183](https://github.com/cloudalchemy/ansible-prometheus/pull/183) ([eRadical](https://github.com/eRadical)) -- Separate test scenarios and run "privileged" one only on master branch [\#175](https://github.com/cloudalchemy/ansible-prometheus/pull/175) ([paulfantom](https://github.com/paulfantom)) - -## [2.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-02-19) -**Merged pull requests:** - -- Add support for retention by size [\#182](https://github.com/cloudalchemy/ansible-prometheus/pull/182) ([SuperQ](https://github.com/SuperQ)) - -## [2.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-31) -## [2.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-30) -**Closed issues:** - -- Allow specifying source url for Prometheus archive [\#176](https://github.com/cloudalchemy/ansible-prometheus/issues/176) - -**Merged pull requests:** - -- New prometheus upstream release! [\#178](https://github.com/cloudalchemy/ansible-prometheus/pull/178) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- New prometheus upstream release! [\#172](https://github.com/cloudalchemy/ansible-prometheus/pull/172) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2019-01-13) -**Fixed bugs:** - -- Default rules not working correctly [\#157](https://github.com/cloudalchemy/ansible-prometheus/issues/157) - -**Closed issues:** - -- Executable HTML files in consoles and console\_libraries in prometheus\_config\_dir [\#168](https://github.com/cloudalchemy/ansible-prometheus/issues/168) -- Wrong home directory for the prometheus user [\#166](https://github.com/cloudalchemy/ansible-prometheus/issues/166) -- Autostart fails [\#162](https://github.com/cloudalchemy/ansible-prometheus/issues/162) -- prometheus\_alert\_rules are not copied as expected [\#148](https://github.com/cloudalchemy/ansible-prometheus/issues/148) - -**Merged pull requests:** - -- Change permissions of console templates to 0644. [\#171](https://github.com/cloudalchemy/ansible-prometheus/pull/171) ([dreig](https://github.com/dreig)) -- Reuse `prometheus\_db\_dir` as prometheus user home directory [\#170](https://github.com/cloudalchemy/ansible-prometheus/pull/170) ([paulfantom](https://github.com/paulfantom)) -- New prometheus upstream release! [\#167](https://github.com/cloudalchemy/ansible-prometheus/pull/167) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- Alert expression fix [\#161](https://github.com/cloudalchemy/ansible-prometheus/pull/161) ([sjal](https://github.com/sjal)) -- Fix running Dry Mode and improved tag usage [\#160](https://github.com/cloudalchemy/ansible-prometheus/pull/160) ([krzyzakp](https://github.com/krzyzakp)) -- New prometheus upstream release! [\#159](https://github.com/cloudalchemy/ansible-prometheus/pull/159) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-29) -**Closed issues:** - -- When used on GCE with gce\_sd\_config discovery scrape config, the ProtectHome=Yes option prevents Prometheus to discover Google Cloud Instances [\#153](https://github.com/cloudalchemy/ansible-prometheus/issues/153) - -**Merged pull requests:** - -- Add clarification surrounding when the .rules file is copied & where it goes [\#156](https://github.com/cloudalchemy/ansible-prometheus/pull/156) ([wbh1](https://github.com/wbh1)) -- Resolves \#153 prometheus homedir set to /tmp [\#155](https://github.com/cloudalchemy/ansible-prometheus/pull/155) ([michalklempa](https://github.com/michalklempa)) -- Document alert relabeling in README.md [\#152](https://github.com/cloudalchemy/ansible-prometheus/pull/152) ([juliusv](https://github.com/juliusv)) - -## [2.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-07) -**Merged pull requests:** - -- Add support for alert relabeling [\#151](https://github.com/cloudalchemy/ansible-prometheus/pull/151) ([juliusv](https://github.com/juliusv)) - -## [2.3.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-10-05) -**Merged pull requests:** - -- New prometheus upstream release! [\#150](https://github.com/cloudalchemy/ansible-prometheus/pull/150) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- move to ansible 2.7 [\#149](https://github.com/cloudalchemy/ansible-prometheus/pull/149) ([paulfantom](https://github.com/paulfantom)) -- Fixed adding ansible comment in templates [\#147](https://github.com/cloudalchemy/ansible-prometheus/pull/147) ([carpenterbees](https://github.com/carpenterbees)) -- Updates to set systemd ulimit for files to infinity [\#146](https://github.com/cloudalchemy/ansible-prometheus/pull/146) ([jalev](https://github.com/jalev)) -- New prometheus upstream release! [\#145](https://github.com/cloudalchemy/ansible-prometheus/pull/145) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- update prometheus release [\#143](https://github.com/cloudalchemy/ansible-prometheus/pull/143) ([paulfantom](https://github.com/paulfantom)) -- fix test condition [\#141](https://github.com/cloudalchemy/ansible-prometheus/pull/141) ([paulfantom](https://github.com/paulfantom)) -- New prometheus upstream release! [\#140](https://github.com/cloudalchemy/ansible-prometheus/pull/140) ([cloudalchemybot](https://github.com/cloudalchemybot)) - -## [2.3.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-09-06) -**Merged pull requests:** - -- Missing protocol causes wrong url generated [\#137](https://github.com/cloudalchemy/ansible-prometheus/pull/137) ([sparanoid](https://github.com/sparanoid)) - -## [2.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-08-12) -**Closed issues:** - -- \[Question\] can't specify blackbox as target [\#134](https://github.com/cloudalchemy/ansible-prometheus/issues/134) -- failed parsing YAML File [\#129](https://github.com/cloudalchemy/ansible-prometheus/issues/129) - -**Merged pull requests:** - -- New prometheus upstream release! [\#136](https://github.com/cloudalchemy/ansible-prometheus/pull/136) ([cloudalchemybot](https://github.com/cloudalchemybot)) -- fixed typo [\#133](https://github.com/cloudalchemy/ansible-prometheus/pull/133) ([shibumi](https://github.com/shibumi)) - -## [2.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-15) -**Merged pull requests:** - -- Fix custom rule/target file copy [\#132](https://github.com/cloudalchemy/ansible-prometheus/pull/132) ([SuperQ](https://github.com/SuperQ)) - -## [2.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-07-01) -**Fixed bugs:** - -- Adding prometheus\_config\_flags\_extra without value [\#127](https://github.com/cloudalchemy/ansible-prometheus/issues/127) - -**Merged pull requests:** - -- use tox, ansible 2.6, and allow using remote docker host [\#130](https://github.com/cloudalchemy/ansible-prometheus/pull/130) ([paulfantom](https://github.com/paulfantom)) - -## [2.2.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-27) -**Merged pull requests:** - -- Allow empty value in config\_flags\_extra [\#128](https://github.com/cloudalchemy/ansible-prometheus/pull/128) ([Turgon37](https://github.com/Turgon37)) -- Allow role being run in check mode [\#126](https://github.com/cloudalchemy/ansible-prometheus/pull/126) ([joelpet](https://github.com/joelpet)) -- add 'tags' support [\#125](https://github.com/cloudalchemy/ansible-prometheus/pull/125) ([soloradish](https://github.com/soloradish)) - -## [2.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-09) -**Merged pull requests:** - -- Prometheus 2.3.0 [\#124](https://github.com/cloudalchemy/ansible-prometheus/pull/124) ([paulfantom](https://github.com/paulfantom)) -- fix prometheus\_targets default value. [\#123](https://github.com/cloudalchemy/ansible-prometheus/pull/123) ([soloradish](https://github.com/soloradish)) - -## [2.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-06-02) -**Merged pull requests:** - -- Let prometheus rule\_files config always be written [\#122](https://github.com/cloudalchemy/ansible-prometheus/pull/122) ([noraab](https://github.com/noraab)) -- specify file name for dest in get\_url call [\#121](https://github.com/cloudalchemy/ansible-prometheus/pull/121) ([sarphram](https://github.com/sarphram)) - -## [2.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-27) -**Fixed bugs:** - -- fix architecture var parsing [\#119](https://github.com/cloudalchemy/ansible-prometheus/pull/119) ([paulfantom](https://github.com/paulfantom)) - -**Closed issues:** - -- Rate limiter in GitHub API [\#115](https://github.com/cloudalchemy/ansible-prometheus/issues/115) - -**Merged pull requests:** - -- use cloudalchemybot when accessing github api [\#120](https://github.com/cloudalchemy/ansible-prometheus/pull/120) ([paulfantom](https://github.com/paulfantom)) - -## [2.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-25) -**Fixed bugs:** - -- Error creating systemd template [\#116](https://github.com/cloudalchemy/ansible-prometheus/issues/116) - -**Merged pull requests:** - -- Deploy console templates [\#118](https://github.com/cloudalchemy/ansible-prometheus/pull/118) ([SuperQ](https://github.com/SuperQ)) -- fix condition in systemd template [\#117](https://github.com/cloudalchemy/ansible-prometheus/pull/117) ([Morsicus](https://github.com/Morsicus)) - -## [2.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-05-17) -**Implemented enhancements:** - -- Provide checksum validation [\#104](https://github.com/cloudalchemy/ansible-prometheus/issues/104) -- Move to molecule 2.x [\#93](https://github.com/cloudalchemy/ansible-prometheus/issues/93) -- Hardening systemd unit for additional security [\#110](https://github.com/cloudalchemy/ansible-prometheus/pull/110) ([paulfantom](https://github.com/paulfantom)) - -**Fixed bugs:** - -- Role fails on RedHat if SELinux is disabled [\#111](https://github.com/cloudalchemy/ansible-prometheus/issues/111) -- Can't download release due to Github redirect the request [\#101](https://github.com/cloudalchemy/ansible-prometheus/issues/101) - -**Closed issues:** - -- Explain how `prometheus\_targets` and `prometheus\_scrape\_config` work [\#105](https://github.com/cloudalchemy/ansible-prometheus/issues/105) - -**Merged pull requests:** - -- take care of SELinux only when it is enabled [\#112](https://github.com/cloudalchemy/ansible-prometheus/pull/112) ([paulfantom](https://github.com/paulfantom)) -- add checksum verification [\#109](https://github.com/cloudalchemy/ansible-prometheus/pull/109) ([paulfantom](https://github.com/paulfantom)) -- move to molecule 2.x [\#108](https://github.com/cloudalchemy/ansible-prometheus/pull/108) ([paulfantom](https://github.com/paulfantom)) -- Offer a better IRC Web clients to users [\#107](https://github.com/cloudalchemy/ansible-prometheus/pull/107) ([Porkepix](https://github.com/Porkepix)) -- Explain how to use prometheus\_targets and prometheus\_scrape\_configs [\#114](https://github.com/cloudalchemy/ansible-prometheus/pull/114) ([paulfantom](https://github.com/paulfantom)) -- Remove prometheus 1.8 support [\#113](https://github.com/cloudalchemy/ansible-prometheus/pull/113) ([paulfantom](https://github.com/paulfantom)) - -## [1.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-20) -**Merged pull requests:** - -- Fix version\_compare warnings [\#106](https://github.com/cloudalchemy/ansible-prometheus/pull/106) ([Porkepix](https://github.com/Porkepix)) -- Separate downloading and unpacking prometheus archive [\#102](https://github.com/cloudalchemy/ansible-prometheus/pull/102) ([paulfantom](https://github.com/paulfantom)) - -## [1.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-17) -**Implemented enhancements:** - -- Allow specifying `latest` version [\#90](https://github.com/cloudalchemy/ansible-prometheus/issues/90) - -**Merged pull requests:** - -- fast-finish failed travis builds [\#100](https://github.com/cloudalchemy/ansible-prometheus/pull/100) ([paulfantom](https://github.com/paulfantom)) -- Use inline template for simpler targets population task [\#99](https://github.com/cloudalchemy/ansible-prometheus/pull/99) ([paulfantom](https://github.com/paulfantom)) - -## [1.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-13) -**Merged pull requests:** - -- allow `latest` as prometheus\_version [\#94](https://github.com/cloudalchemy/ansible-prometheus/pull/94) ([paulfantom](https://github.com/paulfantom)) -- add header for auto.sh script [\#92](https://github.com/cloudalchemy/ansible-prometheus/pull/92) ([paulfantom](https://github.com/paulfantom)) -- Add synchronization of changelog and GitHub releases [\#91](https://github.com/cloudalchemy/ansible-prometheus/pull/91) ([paulfantom](https://github.com/paulfantom)) -- CI automation scripts outsourcing [\#89](https://github.com/cloudalchemy/ansible-prometheus/pull/89) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-10) -**Merged pull requests:** - -- use new filter schema [\#88](https://github.com/cloudalchemy/ansible-prometheus/pull/88) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-07) -**Merged pull requests:** - -- Quick fix to allow multi-arch environments support [\#87](https://github.com/cloudalchemy/ansible-prometheus/pull/87) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-05) -**Merged pull requests:** - -- Retry when connecting to external services [\#86](https://github.com/cloudalchemy/ansible-prometheus/pull/86) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-04-03) -**Merged pull requests:** - -- test parametrization [\#85](https://github.com/cloudalchemy/ansible-prometheus/pull/85) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-26) -**Merged pull requests:** - -- Ubuntu bionic \(18.04\) support [\#82](https://github.com/cloudalchemy/ansible-prometheus/pull/82) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-24) -**Merged pull requests:** - -- ansible 2.5 [\#84](https://github.com/cloudalchemy/ansible-prometheus/pull/84) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-22) -**Merged pull requests:** - -- Modify when-statement to not include jinja2 templating delimiters [\#83](https://github.com/cloudalchemy/ansible-prometheus/pull/83) ([swesterveld](https://github.com/swesterveld)) - -## [1.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) -## [1.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-15) -**Merged pull requests:** - -- Describe jmespath installation to virtualenv [\#81](https://github.com/cloudalchemy/ansible-prometheus/pull/81) ([bngsudheer](https://github.com/bngsudheer)) -- SELinux support [\#79](https://github.com/cloudalchemy/ansible-prometheus/pull/79) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-03-09) -**Merged pull requests:** - -- bump prometheus version to 2.2 [\#80](https://github.com/cloudalchemy/ansible-prometheus/pull/80) ([paulfantom](https://github.com/paulfantom)) - -## [1.0.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-25) -**Implemented enhancements:** - -- Support remote read option [\#73](https://github.com/cloudalchemy/ansible-prometheus/issues/73) -- Run Prometheus server without alertmanager option [\#18](https://github.com/cloudalchemy/ansible-prometheus/issues/18) - -**Fixed bugs:** - -- Wrong directory permissions [\#74](https://github.com/cloudalchemy/ansible-prometheus/issues/74) -- metrics\_path for local Prometheus endpoint [\#19](https://github.com/cloudalchemy/ansible-prometheus/issues/19) -- Wrong indent [\#36](https://github.com/cloudalchemy/ansible-prometheus/pull/36) ([paulfantom](https://github.com/paulfantom)) - -**Closed issues:** - -- Allow multiple targets templates files. [\#58](https://github.com/cloudalchemy/ansible-prometheus/issues/58) -- Outdated documentation [\#1](https://github.com/cloudalchemy/ansible-prometheus/issues/1) - -**Merged pull requests:** - -- Custom target and rule files [\#59](https://github.com/cloudalchemy/ansible-prometheus/pull/59) ([paulfantom](https://github.com/paulfantom)) - -## [0.12.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) -**Merged pull requests:** - -- Fix typo [\#78](https://github.com/cloudalchemy/ansible-prometheus/pull/78) ([swesterveld](https://github.com/swesterveld)) - -## [0.12.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-14) -**Merged pull requests:** - -- Make Prometheus daemon restart/reload with sudo privileges. [\#77](https://github.com/cloudalchemy/ansible-prometheus/pull/77) ([swesterveld](https://github.com/swesterveld)) - -## [0.12.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-11) -**Merged pull requests:** - -- add remote\_read functionality [\#76](https://github.com/cloudalchemy/ansible-prometheus/pull/76) ([paulfantom](https://github.com/paulfantom)) - -## [0.11.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) -**Fixed bugs:** - -- change file permissions and ditch prometheus\_root\_dir [\#75](https://github.com/cloudalchemy/ansible-prometheus/pull/75) ([paulfantom](https://github.com/paulfantom)) - -## [0.11.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-10) -**Merged pull requests:** - -- specify which tasks should use superuser permissions [\#72](https://github.com/cloudalchemy/ansible-prometheus/pull/72) ([paulfantom](https://github.com/paulfantom)) -- adapt prometheus binary placement to hier\(7\) [\#71](https://github.com/cloudalchemy/ansible-prometheus/pull/71) ([paulfantom](https://github.com/paulfantom)) - -## [0.11.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-07) -**Closed issues:** - -- File copy globbing [\#57](https://github.com/cloudalchemy/ansible-prometheus/issues/57) - -**Merged pull requests:** - -- Enable check mode in ansible [\#70](https://github.com/cloudalchemy/ansible-prometheus/pull/70) ([paulfantom](https://github.com/paulfantom)) - -## [0.11.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-06) -## [0.11.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) -**Merged pull requests:** - -- Add support for remote write [\#69](https://github.com/cloudalchemy/ansible-prometheus/pull/69) ([paulfantom](https://github.com/paulfantom)) - -## [0.10.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-02-03) -**Merged pull requests:** - -- Update ansible versions in tests [\#68](https://github.com/cloudalchemy/ansible-prometheus/pull/68) ([paulfantom](https://github.com/paulfantom)) - -## [0.10.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-22) -**Merged pull requests:** - -- Set global values to prometheus defaults [\#67](https://github.com/cloudalchemy/ansible-prometheus/pull/67) ([paulfantom](https://github.com/paulfantom)) - -## [0.10.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-20) -**Implemented enhancements:** - -- Add default CriticalRAMLoad alert rules [\#63](https://github.com/cloudalchemy/ansible-prometheus/issues/63) - -**Merged pull requests:** - -- Prometheus 2.1 [\#66](https://github.com/cloudalchemy/ansible-prometheus/pull/66) ([paulfantom](https://github.com/paulfantom)) - -## [0.10.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) -**Merged pull requests:** - -- added CriticalRAMLoad [\#65](https://github.com/cloudalchemy/ansible-prometheus/pull/65) ([rdemachkovych](https://github.com/rdemachkovych)) - -## [0.10.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-17) -**Merged pull requests:** - -- a little bit of python3 support [\#64](https://github.com/cloudalchemy/ansible-prometheus/pull/64) ([aeber](https://github.com/aeber)) - -## [0.10.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-16) -**Closed issues:** - -- More preflight checks? [\#16](https://github.com/cloudalchemy/ansible-prometheus/issues/16) - -**Merged pull requests:** - -- validate prometheus\_config\_flags\_extra [\#62](https://github.com/cloudalchemy/ansible-prometheus/pull/62) ([paulfantom](https://github.com/paulfantom)) - -## [0.10.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-15) -**Implemented enhancements:** - -- Support more operating systems in CI pipeline and meta/main.yml [\#42](https://github.com/cloudalchemy/ansible-prometheus/issues/42) - -**Merged pull requests:** - -- \[ci skip\] author info [\#61](https://github.com/cloudalchemy/ansible-prometheus/pull/61) ([paulfantom](https://github.com/paulfantom)) -- multiple target files loaded with file\_sd [\#60](https://github.com/cloudalchemy/ansible-prometheus/pull/60) ([paulfantom](https://github.com/paulfantom)) - -## [0.9.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-13) -**Merged pull requests:** - -- use custom docker images in CI pipeline [\#43](https://github.com/cloudalchemy/ansible-prometheus/pull/43) ([paulfantom](https://github.com/paulfantom)) - -## [0.9.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-11) -**Merged pull requests:** - -- cleaner tests [\#55](https://github.com/cloudalchemy/ansible-prometheus/pull/55) ([paulfantom](https://github.com/paulfantom)) - -## [0.9.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-07) -**Closed issues:** - -- Convert scrape\_configs to simple attribute tree [\#45](https://github.com/cloudalchemy/ansible-prometheus/issues/45) - -**Merged pull requests:** - -- added i386 arch [\#54](https://github.com/cloudalchemy/ansible-prometheus/pull/54) ([rdemachkovych](https://github.com/rdemachkovych)) -- Update README.md [\#53](https://github.com/cloudalchemy/ansible-prometheus/pull/53) ([paulfantom](https://github.com/paulfantom)) - -## [0.9.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-03) -**Closed issues:** - -- What version of molecule are the tests written for? [\#44](https://github.com/cloudalchemy/ansible-prometheus/issues/44) - -**Merged pull requests:** - -- Update generatetag.sh [\#52](https://github.com/cloudalchemy/ansible-prometheus/pull/52) ([paulfantom](https://github.com/paulfantom)) -- Simplify scrape configs [\#50](https://github.com/cloudalchemy/ansible-prometheus/pull/50) ([SuperQ](https://github.com/SuperQ)) - -## [0.9.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) -**Merged pull requests:** - -- Docs [\#51](https://github.com/cloudalchemy/ansible-prometheus/pull/51) ([paulfantom](https://github.com/paulfantom)) - -## [0.8.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2018-01-02) -**Merged pull requests:** - -- Update generatetag.sh [\#49](https://github.com/cloudalchemy/ansible-prometheus/pull/49) ([paulfantom](https://github.com/paulfantom)) -- support older raspberry pi [\#48](https://github.com/cloudalchemy/ansible-prometheus/pull/48) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.14](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-31) -**Merged pull requests:** - -- Add link to demo site [\#47](https://github.com/cloudalchemy/ansible-prometheus/pull/47) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.13](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-30) -**Merged pull requests:** - -- Clean scrape config [\#46](https://github.com/cloudalchemy/ansible-prometheus/pull/46) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) -**Merged pull requests:** - -- armv7l ansible arch translates to armv7 go arch [\#41](https://github.com/cloudalchemy/ansible-prometheus/pull/41) ([anisse](https://github.com/anisse)) - -## [0.7.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-27) -**Merged pull requests:** - -- storage retention [\#40](https://github.com/cloudalchemy/ansible-prometheus/pull/40) ([paulfantom](https://github.com/paulfantom)) -- change alert rules name; take rules from wildcard [\#38](https://github.com/cloudalchemy/ansible-prometheus/pull/38) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.10](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-22) -**Merged pull requests:** - -- Update README.md [\#39](https://github.com/cloudalchemy/ansible-prometheus/pull/39) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-18) -**Implemented enhancements:** - -- metrics\_path for local Prometheus endpoint [\#27](https://github.com/cloudalchemy/ansible-prometheus/issues/27) - -**Merged pull requests:** - -- Fix default port for alertmanager [\#37](https://github.com/cloudalchemy/ansible-prometheus/pull/37) ([paulfantom](https://github.com/paulfantom)) -- do not copy alert rules when there are none [\#35](https://github.com/cloudalchemy/ansible-prometheus/pull/35) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.8](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) -**Merged pull requests:** - -- Issue27 [\#32](https://github.com/cloudalchemy/ansible-prometheus/pull/32) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) -**Merged pull requests:** - -- add disk usage alert and reboot alert [\#31](https://github.com/cloudalchemy/ansible-prometheus/pull/31) ([paulfantom](https://github.com/paulfantom)) -- add comments; clear README [\#30](https://github.com/cloudalchemy/ansible-prometheus/pull/30) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-17) -**Merged pull requests:** - -- CI fix [\#29](https://github.com/cloudalchemy/ansible-prometheus/pull/29) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) -**Merged pull requests:** - -- leave empty prometheus\_web\_external\_url for default [\#28](https://github.com/cloudalchemy/ansible-prometheus/pull/28) ([rdemachkovych](https://github.com/rdemachkovych)) - -## [0.7.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) -**Merged pull requests:** - -- metrics path [\#24](https://github.com/cloudalchemy/ansible-prometheus/pull/24) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-15) -**Closed issues:** - -- Use systemd for service control [\#25](https://github.com/cloudalchemy/ansible-prometheus/issues/25) - -**Merged pull requests:** - -- fully switch to systemd module [\#26](https://github.com/cloudalchemy/ansible-prometheus/pull/26) ([paulfantom](https://github.com/paulfantom)) -- auto set go architecture [\#23](https://github.com/cloudalchemy/ansible-prometheus/pull/23) ([paulfantom](https://github.com/paulfantom)) -- simplify setting custom configuration file [\#21](https://github.com/cloudalchemy/ansible-prometheus/pull/21) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-08) -**Merged pull requests:** - -- Add newline before \[Unit\] section in service file [\#20](https://github.com/cloudalchemy/ansible-prometheus/pull/20) ([ecksun](https://github.com/ecksun)) - -## [0.7.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-06) -**Closed issues:** - -- Debian support [\#3](https://github.com/cloudalchemy/ansible-prometheus/issues/3) -- Better handling of alerting rules [\#2](https://github.com/cloudalchemy/ansible-prometheus/issues/2) - -**Merged pull requests:** - -- Update README.md [\#17](https://github.com/cloudalchemy/ansible-prometheus/pull/17) ([paulfantom](https://github.com/paulfantom)) -- Typo [\#14](https://github.com/cloudalchemy/ansible-prometheus/pull/14) ([paulfantom](https://github.com/paulfantom)) -- Stop pipeline on any error [\#13](https://github.com/cloudalchemy/ansible-prometheus/pull/13) ([paulfantom](https://github.com/paulfantom)) - -## [0.7.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) -**Merged pull requests:** - -- Alert rules and debian support [\#11](https://github.com/cloudalchemy/ansible-prometheus/pull/11) ([paulfantom](https://github.com/paulfantom)) - -## [0.6.12](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-12-01) -**Merged pull requests:** - -- Fix tagging [\#12](https://github.com/cloudalchemy/ansible-prometheus/pull/12) ([paulfantom](https://github.com/paulfantom)) - -## [0.6.11](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-30) -**Merged pull requests:** - -- Prometheus job [\#10](https://github.com/cloudalchemy/ansible-prometheus/pull/10) ([rdemachkovych](https://github.com/rdemachkovych)) - -## [0.6.9](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) -**Closed issues:** - -- Parallel CI build [\#4](https://github.com/cloudalchemy/ansible-prometheus/issues/4) - -**Merged pull requests:** - -- Update main.yml [\#9](https://github.com/cloudalchemy/ansible-prometheus/pull/9) ([paulfantom](https://github.com/paulfantom)) -- prometheus\_external\_labels variable assignment dynamically [\#6](https://github.com/cloudalchemy/ansible-prometheus/pull/6) ([rdemachkovych](https://github.com/rdemachkovych)) - -## [0.6.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) -**Merged pull requests:** - -- Update generatetag.sh [\#8](https://github.com/cloudalchemy/ansible-prometheus/pull/8) ([paulfantom](https://github.com/paulfantom)) - -## [0.6.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-28) -**Merged pull requests:** - -- Update generatetag.sh [\#7](https://github.com/cloudalchemy/ansible-prometheus/pull/7) ([paulfantom](https://github.com/paulfantom)) -- test different ansible versions [\#5](https://github.com/cloudalchemy/ansible-prometheus/pull/5) ([paulfantom](https://github.com/paulfantom)) - -## [0.6.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) -## [0.6.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-23) -## [0.6.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) -## [0.6.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) -## [0.6.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-22) -## [0.5.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) -## [0.5.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-13) -## [0.5.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-11-07) -## [0.5.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-22) -## [0.5.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-17) -## [0.5.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-16) -## [0.4.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-10-05) -## [0.4.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-09-27) -## [0.3.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) -## [0.3.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-08-21) -## [0.3.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) -## [0.2.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-21) -## [0.1.7](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) -## [0.1.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) -## [0.1.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-11) -## [0.1.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-07-10) -## [0.1.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-20) -## [0.1.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-14) -## [0.1.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-13) -## [0.1.0](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-06-06) -## [0.0.6](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) -## [0.0.5](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-23) -## [0.0.4](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-15) -## [0.0.3](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) -## [0.0.2](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-05-09) -## [0.0.1](https://galaxy.ansible.com/cloudalchemy/prometheus) (2017-04-27) - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/roles/prometheus/CONTRIBUTING.md b/roles/prometheus/CONTRIBUTING.md deleted file mode 100644 index 897372dd..00000000 --- a/roles/prometheus/CONTRIBUTING.md +++ /dev/null @@ -1,97 +0,0 @@ -# Contributor Guideline - -This document provides an overview of how you can participate in improving this project or extending it. We are -grateful for all your help: bug reports and fixes, code contributions, documentation or ideas. Feel free to join, we -appreciate your support!! - -## Communication - -### GitHub repositories - -Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report -bugs, ask questions, and request new features . - -## git and GitHub - -In order to contribute code please: - -1. Fork the project on GitHub -2. Clone the project -3. Add changes (and tests) -4. Commit and push -5. Create a merge-request - -To have your code merged, see the expectations listed below. - -You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo). - -Please follow common commit best-practices. Be explicit, have a short summary, a well-written description and -references. This is especially important for the merge-request. - -Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCommitMessages) and -[here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message). - -## Releases - -We try to stick to semantic versioning and our releases are automated. Release is created by assigning a keyword (in a -way similar to travis [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build)) to a -commit with merge request. Available keywords are (square brackets are important!): - -* `[patch]`, `[fix]` - for PATCH version release -* `[minor]`, `[feature]`, `[feat]` - for MINOR version release -* `[major]`, `[breaking change]` - for MAJOR version release - -## Changelog - -Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs -and labels. - -## Expectations - -### Keep it simple - -We try to provide production ready ansible roles which should be as much zero-conf as possible but this doesn't mean to -overcomplicate things. Just follow [KISS](https://en.wikipedia.org/wiki/KISS_principle). - -### Be explicit - -* Please avoid using nonsensical property and variable names. -* Use self-describing attribute names for user configuration. -* In case of failures, communicate what happened and why a failure occurs to the user. Make it easy to track the code -or action that produced the error. Try to catch and handle errors if possible to provide improved failure messages. - - -### Add tests - -We are striving to use at least two test scenarios located in [/molecule](molecule) directory. First one -([default](molecule/default)) is testing default configuration without any additional variables, second one -([alternative](molecule/alternative)) is testing what happens when many variables from -[/defaults/main.yml](defaults/main.yml) are changed. When adding new functionalities please add tests to proper -scenarios. Tests are written in testinfra framework and are located in `/tests` subdirectory of scenario directory -(for example default tests are in [/molecule/default/tests](molecule/default/tests)). -More information about: - - [testinfra](http://testinfra.readthedocs.io/en/latest/index.html) - - [molecule](https://molecule.readthedocs.io/en/latest/index.html) - -### Follow best practices - -Please follow [ansible best practices](http://docs.ansible.com/ansible/latest/playbooks_best_practices.html) and -especially provide meaningful names to tasks and even comments where needed. - -Our test framework automatically lints code with [`yamllint`](https://yamllint.readthedocs.io) and -[`ansible-lint`](https://github.com/willthames/ansible-lint) programs so be sure to follow their rules. - -Remember: Code is generally read much more often than written. - -### Use Markdown - -Wherever possible, please refrain from any other formats and stick to simple markdown. - -## Requirements regarding roles design - -We are trying to create the best and most secure installation method for non-containerized prometheus stack components. -To accomplish this all roles need to support: - -- current and at least one previous ansible version (wherever possible we try to support 2 previous ansible versions) -- systemd as the only available process manager -- at least latest debian and CentOS distributions diff --git a/roles/prometheus/LICENSE b/roles/prometheus/LICENSE deleted file mode 100644 index 353992c6..00000000 --- a/roles/prometheus/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017-2018 Pawel Krupa, Roman Demachkovych - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/roles/prometheus/README.md b/roles/prometheus/README.md deleted file mode 100644 index b3279d36..00000000 --- a/roles/prometheus/README.md +++ /dev/null @@ -1,156 +0,0 @@ -

prometheus logo

- -# Ansible Role: prometheus - -[![Build Status](https://travis-ci.org/cloudalchemy/ansible-prometheus.svg?branch=master)](https://travis-ci.org/cloudalchemy/ansible-prometheus) -[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT) -[![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.prometheus-blue.svg)](https://galaxy.ansible.com/cloudalchemy/prometheus/) -[![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-prometheus.svg)](https://github.com/cloudalchemy/ansible-prometheus/tags) - -## Description - -Deploy [Prometheus](https://github.com/prometheus/prometheus) monitoring system using ansible. - -### Upgradability notice - -When upgrading from <= 2.4.0 version of this role to >= 2.4.1 please turn off your prometheus instance. More in [2.4.1 release notes](https://github.com/cloudalchemy/ansible-prometheus/releases/tag/2.4.1) - -## Requirements - -- Ansible >= 2.7 (It might work on previous versions, but we cannot guarantee it) -- jmespath on deployer machine. If you are using Ansible from a Python virtualenv, install *jmespath* to the same virtualenv via pip. -- gnu-tar on Mac deployer host (`brew install gnu-tar`) - -## Role Variables - -All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below. - -| Name | Default Value | Description | -| -------------- | ------------- | -----------------------------------| -| `prometheus_version` | 2.24.1 | Prometheus package version. Also accepts `latest` as parameter. Only prometheus 2.x is supported | -| `prometheus_skip_install` | false | Prometheus installation tasks gets skipped when set to true. | -| `prometheus_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `prometheus` AND `promtool` binaries are stored on host on which ansible is ran. This overrides `prometheus_version` parameter | -| `prometheus_config_dir` | /etc/prometheus | Path to directory with prometheus configuration | -| `prometheus_db_dir` | /var/lib/prometheus | Path to directory with prometheus database | -| `prometheus_web_listen_address` | "0.0.0.0:9090" | Address on which prometheus will be listening | -| `prometheus_web_external_url` | "" | External address on which prometheus is available. Useful when behind reverse proxy. Ex. `http://example.org/prometheus` | -| `prometheus_storage_retention` | "30d" | Data retention period | -| `prometheus_storage_retention_size` | "0" | Data retention period by size | -| `prometheus_config_flags_extra` | {} | Additional configuration flags passed to prometheus binary at startup | -| `prometheus_alertmanager_config` | [] | Configuration responsible for pointing where alertmanagers are. This should be specified as list in yaml format. It is compatible with official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alertmanager_config) | -| `prometheus_alert_relabel_configs` | [] | Alert relabeling rules. This should be specified as list in yaml format. It is compatible with the official [](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alert_relabel_configs) | -| `prometheus_global` | { scrape_interval: 60s, scrape_timeout: 15s, evaluation_interval: 15s } | Prometheus global config. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#configuration-file) | -| `prometheus_remote_write` | [] | Remote write. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | -| `prometheus_remote_read` | [] | Remote read. Compatible with [official configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) | -| `prometheus_external_labels` | environment: "{{ ansible_fqdn \| default(ansible_host) \| default(inventory_hostname) }}" | Provide map of additional labels which will be added to any time series or alerts when communicating with external systems | -| `prometheus_targets` | {} | Targets which will be scraped. Better example is provided in our [demo site](https://github.com/cloudalchemy/demo-site/blob/2a8a56fc10ce613d8b08dc8623230dace6704f9a/group_vars/all/vars#L8) | -| `prometheus_scrape_configs` | [defaults/main.yml#L58](https://github.com/cloudalchemy/ansible-prometheus/blob/ff7830d06ba57be1177f2b6fca33a4dd2d97dc20/defaults/main.yml#L47) | Prometheus scrape jobs provided in same format as in [official docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) | -| `prometheus_config_file` | "prometheus.yml.j2" | Variable used to provide custom prometheus configuration file in form of ansible template | -| `prometheus_alert_rules` | [defaults/main.yml#L81](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L85) | Full list of alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/ansible_managed.rules`. Alerting rules can be also provided by other files located in `{{ prometheus_config_dir }}/rules/` which have `*.rules` extension | -| `prometheus_alert_rules_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L78) | List of folders where ansible will look for files containing alerting rules which will be copied to `{{ prometheus_config_dir }}/rules/`. Files must have `*.rules` extension | -| `prometheus_static_targets_files` | [defaults/main.yml#L78](https://github.com/cloudalchemy/ansible-prometheus/blob/73d6df05a775ee5b736ac8f28d5605f2a975d50a/defaults/main.yml#L81) | List of folders where ansible will look for files containing custom static target configuration files which will be copied to `{{ prometheus_config_dir }}/file_sd/`. | - - -### Relation between `prometheus_scrape_configs` and `prometheus_targets` - -#### Short version - -`prometheus_targets` is just a map used to create multiple files located in "{{ prometheus_config_dir }}/file_sd" directory. Where file names are composed from top-level keys in that map with `.yml` suffix. Those files store [file_sd scrape targets data](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config) and they need to be read in `prometheus_scrape_configs`. - -#### Long version - -A part of *prometheus.yml* configuration file which describes what is scraped by prometheus is stored in `prometheus_scrape_configs`. For this variable same configuration options as described in [prometheus docs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#) are used. - -Meanwhile `prometheus_targets` is our way of adopting [prometheus scrape type `file_sd`](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#). It defines a map of files with their content. A top-level keys are base names of files which need to have their own scrape job in `prometheus_scrape_configs` and values are a content of those files. - -All this mean that you CAN use custom `prometheus_scrape_configs` with `prometheus_targets` set to `{}`. However when you set anything in `prometheus_targets` it needs to be mapped to `prometheus_scrape_configs`. If it isn't you'll get an error in preflight checks. - -#### Example - -Lets look at our default configuration, which shows all features. By default we have this `prometheus_targets`: -``` -prometheus_targets: - node: # This is a base file name. File is located in "{{ prometheus_config_dir }}/file_sd/<>.yml" - - targets: # - - localhost:9100 # All this is a targets section in file_sd format - labels: # - env: test # -``` -Such config will result in creating one file named `node.yml` in `{{ prometheus_config_dir }}/file_sd` directory. - -Next this file needs to be loaded into scrape config. Here is modified version of our default `prometheus_scrape_configs`: -``` -prometheus_scrape_configs: - - job_name: "prometheus" # Custom scrape job, here using `static_config` - metrics_path: "/metrics" - static_configs: - - targets: - - "localhost:9090" - - job_name: "example-node-file-servicediscovery" - file_sd_configs: - - files: - - "{{ prometheus_config_dir }}/file_sd/node.yml" # This line loads file created from `prometheus_targets` -``` - -## Example - -### Playbook - -```yaml ---- -- hosts: all - roles: - - cloudalchemy.prometheus - vars: - prometheus_targets: - node: - - targets: - - localhost:9100 - - demo.cloudalchemy.org:9100 - labels: - env: demosite -``` - -### Demo site - -Prometheus organization provide a demo site for full monitoring solution based on prometheus and grafana. Repository with code and links to running instances is [available on github](https://github.com/prometheus/demo-site). - -### Defining alerting rules files - -Alerting rules are defined in `prometheus_alert_rules` variable. Format is almost identical to one defined in[ Prometheus 2.0 documentation](https://prometheus.io/docs/prometheus/latest/configuration/template_examples/). -Due to similarities in templating engines, every templates should be wrapped in `{% raw %}` and `{% endraw %}` statements. Example is provided in [defaults/main.yml](defaults/main.yml) file. - -## Local Testing - -The preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v2.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. -We are using tox to simplify process of testing on multiple ansible versions. To install tox execute: -```sh -pip3 install tox -``` -To run tests on all ansible versions (WARNING: this can take some time) -```sh -tox -``` -To run a custom molecule command on custom environment with only default test scenario: -```sh -tox -e py35-ansible28 -- molecule test -s default -``` -For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/). - -If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests. - -## Travis CI - -Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which will take more time than local testing, so please be patient. - -## Contributing - -See [contributor guideline](CONTRIBUTING.md). - -## Troubleshooting - -See [troubleshooting](TROUBLESHOOTING.md). - -## License - -This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details. diff --git a/roles/prometheus/TROUBLESHOOTING.md b/roles/prometheus/TROUBLESHOOTING.md deleted file mode 100644 index 748f6a5f..00000000 --- a/roles/prometheus/TROUBLESHOOTING.md +++ /dev/null @@ -1,3 +0,0 @@ -# Troubleshooting - - diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml deleted file mode 100644 index dc8a19f1..00000000 --- a/roles/prometheus/defaults/main.yml +++ /dev/null @@ -1,213 +0,0 @@ ---- -prometheus_version: 2.24.1 -prometheus_binary_local_dir: '' -prometheus_skip_install: false - -prometheus_config_dir: /etc/prometheus -prometheus_db_dir: /var/lib/prometheus - -prometheus_web_listen_address: "0.0.0.0:9090" -prometheus_web_external_url: '' - -prometheus_storage_retention: "30d" -# Available since Prometheus 2.7.0 -# [EXPERIMENTAL] Maximum number of bytes that can be stored for blocks. Units -# supported: KB, MB, GB, TB, PB. -prometheus_storage_retention_size: "0" - -prometheus_config_flags_extra: {} -# prometheus_config_flags_extra: -# storage.tsdb.retention: 15d -# alertmanager.timeout: 10s - -prometheus_alertmanager_config: [] -# prometheus_alertmanager_config: -# - scheme: https -# path_prefix: alertmanager/ -# basic_auth: -# username: user -# password: pass -# static_configs: -# - targets: ["127.0.0.1:9093"] -# proxy_url: "127.0.0.2" - -prometheus_alert_relabel_configs: [] -# prometheus_alert_relabel_configs: -# - action: labeldrop -# regex: replica - -prometheus_global: - scrape_interval: 15s - scrape_timeout: 10s - evaluation_interval: 15s - -prometheus_remote_write: [] -# prometheus_remote_write: -# - url: https://dev.kausal.co/prom/push -# basic_auth: -# password: FOO - -prometheus_remote_read: [] -# prometheus_remote_read: -# - url: https://demo.cloudalchemy.org:9201/read -# basic_auth: -# password: FOO - -prometheus_external_labels: - environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}" - -prometheus_targets: {} -# node: -# - targets: -# - localhost:9100 -# labels: -# env: test - -prometheus_scrape_configs: - - job_name: "prometheus" - metrics_path: "{{ prometheus_metrics_path }}" - static_configs: - - targets: - - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" - - job_name: "node" - file_sd_configs: - - files: - - "{{ prometheus_config_dir }}/file_sd/node.yml" - -# Alternative config file name, searched in ansible templates path. -prometheus_config_file: 'prometheus.yml.j2' - -prometheus_alert_rules_files: - - prometheus/rules/*.rules - -prometheus_static_targets_files: - - prometheus/targets/*.yml - - prometheus/targets/*.json - -prometheus_alert_rules: - - alert: Watchdog - expr: vector(1) - for: 10m - labels: - severity: warning - annotations: - description: "This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\n\"DeadMansSnitch\" integration in PagerDuty." - summary: 'Ensure entire alerting pipeline is functional' - - alert: InstanceDown - expr: 'up == 0' - for: 5m - labels: - severity: critical - annotations: - description: '{% raw %}{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.{% endraw %}' - summary: '{% raw %}Instance {{ $labels.instance }} down{% endraw %}' - - alert: RebootRequired - expr: 'node_reboot_required > 0' - labels: - severity: warning - annotations: - description: '{% raw %}{{ $labels.instance }} requires a reboot.{% endraw %}' - summary: '{% raw %}Instance {{ $labels.instance }} - reboot required{% endraw %}' - - alert: NodeFilesystemSpaceFillingUp - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up.{% endraw %}' - summary: 'Filesystem is predicted to run out of space within the next 24 hours.' - expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: warning - - alert: NodeFilesystemSpaceFillingUp - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up fast.{% endraw %}' - summary: 'Filesystem is predicted to run out of space within the next 4 hours.' - expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: critical - - alert: NodeFilesystemAlmostOutOfSpace - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' - summary: 'Filesystem has less than 5% space left.' - expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: warning - - alert: NodeFilesystemAlmostOutOfSpace - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.{% endraw %}' - summary: 'Filesystem has less than 3% space left.' - expr: "(\n node_filesystem_avail_bytes{job=\"node\",fstype!=\"\"} / node_filesystem_size_bytes{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: critical - - alert: NodeFilesystemFilesFillingUp - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up.{% endraw %}' - summary: 'Filesystem is predicted to run out of inodes within the next 24 hours.' - expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 40\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 24*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: warning - - alert: NodeFilesystemFilesFillingUp - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up fast.{% endraw %}' - summary: 'Filesystem is predicted to run out of inodes within the next 4 hours.' - expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 20\nand\n predict_linear(node_filesystem_files_free{job=\"node\",fstype!=\"\"}[6h], 4*60*60) < 0\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: critical - - alert: NodeFilesystemAlmostOutOfFiles - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' - summary: 'Filesystem has less than 5% inodes left.' - expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 5\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: warning - - alert: NodeFilesystemAlmostOutOfFiles - annotations: - description: '{% raw %}Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.{% endraw %}' - summary: 'Filesystem has less than 3% inodes left.' - expr: "(\n node_filesystem_files_free{job=\"node\",fstype!=\"\"} / node_filesystem_files{job=\"node\",fstype!=\"\"} * 100 < 3\nand\n node_filesystem_readonly{job=\"node\",fstype!=\"\"} == 0\n)\n" - for: 1h - labels: - severity: critical - - alert: NodeNetworkReceiveErrs - annotations: - description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} receive errors in the last two minutes.{% endraw %}' - summary: 'Network interface is reporting many receive errors.' - expr: "increase(node_network_receive_errs_total[2m]) > 10\n" - for: 1h - labels: - severity: warning - - alert: NodeNetworkTransmitErrs - annotations: - description: '{% raw %}{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} transmit errors in the last two minutes.{% endraw %}' - summary: 'Network interface is reporting many transmit errors.' - expr: "increase(node_network_transmit_errs_total[2m]) > 10\n" - for: 1h - labels: - severity: warning - - alert: NodeHighNumberConntrackEntriesUsed - annotations: - description: '{% raw %}{{ $value | humanizePercentage }} of conntrack entries are used{% endraw %}' - summary: 'Number of conntrack are getting close to the limit' - expr: "(node_nf_conntrack_entries / node_nf_conntrack_entries_limit) > 0.75\n" - labels: - severity: warning - - alert: NodeClockSkewDetected - annotations: - message: '{% raw %}Clock on {{ $labels.instance }} is out of sync by more than 300s. Ensure NTP is configured correctly on this host.{% endraw %}' - summary: 'Clock skew detected.' - expr: "(\n node_timex_offset_seconds > 0.05\nand\n deriv(node_timex_offset_seconds[5m]) >= 0\n)\nor\n(\n node_timex_offset_seconds < -0.05\nand\n deriv(node_timex_offset_seconds[5m]) <= 0\n)\n" - for: 10m - labels: - severity: warning - - alert: NodeClockNotSynchronising - annotations: - message: '{% raw %}Clock on {{ $labels.instance }} is not synchronising. Ensure NTP is configured on this host.{% endraw %}' - summary: 'Clock not synchronising.' - expr: "min_over_time(node_timex_sync_status[5m]) == 0\n" - for: 10m - labels: - severity: warning diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml deleted file mode 100644 index aba85189..00000000 --- a/roles/prometheus/handlers/main.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: restart prometheus - become: true - systemd: - daemon_reload: true - name: prometheus - state: restarted - -- name: reload prometheus - become: true - systemd: - name: prometheus - state: reloaded diff --git a/roles/prometheus/meta/main.yml b/roles/prometheus/meta/main.yml deleted file mode 100644 index 0fb2b817..00000000 --- a/roles/prometheus/meta/main.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -galaxy_info: - author: Roman Demachkovych, Pawel Krupa - description: Prometheus monitoring system configuration and management - license: MIT - company: none - min_ansible_version: 2.7 - platforms: - - name: Ubuntu - versions: - - bionic - - xenial - - name: Debian - versions: - - stretch - - buster - - name: EL - versions: - - 7 - - 8 - - name: Fedora - versions: - - 30 - - 31 - galaxy_tags: - - monitoring - - prometheus - - metrics - - alerts - - alerting - - molecule - - cloud - -dependencies: [] diff --git a/roles/prometheus/molecule/alternative/molecule.yml b/roles/prometheus/molecule/alternative/molecule.yml deleted file mode 100644 index c03bcf2a..00000000 --- a/roles/prometheus/molecule/alternative/molecule.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -platforms: - - name: bionic - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: xenial - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: stretch - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:debian-9 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: buster - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:debian-10 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: centos7 - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:centos-7 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: centos8 - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:centos-8 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - groups: - - python3 - - name: fedora - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:fedora-30 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - groups: - - python3 -provisioner: - name: ansible - playbooks: - prepare: prepare.yml - converge: playbook.yml - inventory: - group_vars: - python3: - ansible_python_interpreter: /usr/bin/python3 -verifier: - name: testinfra diff --git a/roles/prometheus/molecule/alternative/playbook.yml b/roles/prometheus/molecule/alternative/playbook.yml deleted file mode 100644 index 68c46b93..00000000 --- a/roles/prometheus/molecule/alternative/playbook.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -- name: Run role - hosts: all - any_errors_fatal: true - roles: - - ansible-prometheus - vars: - prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64' - prometheus_config_dir: /opt/prom/etc - prometheus_db_dir: /opt/prom/lib - prometheus_web_listen_address: "127.0.0.1:9090" - prometheus_web_external_url: "http://127.0.0.1:9090/prometheus" - prometheus_storage_retention: "60d" - prometheus_storage_retention_size: "1GB" - prometheus_config_flags_extra: - alertmanager.timeout: 10s - web.enable-admin-api: - prometheus_alertmanager_config: - - scheme: https - path_prefix: /alertmanager - basic_auth: - username: user - password: pass - static_configs: - - targets: ["127.0.0.1:9090"] - proxy_url: "127.0.0.2" - prometheus_alert_relabel_configs: - - action: labeldrop - regex: replica - prometheus_global: - scrape_interval: 3s - scrape_timeout: 2s - evaluation_interval: 10s - prometheus_remote_write: - - url: http://influx.cloudalchemy.org:8086/api/v1/prom/write?db=test - basic_auth: - username: prometheus - password: SuperSecret - prometheus_remote_read: - - url: http://influx.cloudalchemy.org:8086/api/v1/prom/read?db=cloudalchemy - prometheus_external_labels: - environment: "alternative" - prometheus_targets: - node: - - targets: - - demo.cloudalchemy.org:9100 - - influx.cloudalchemy.org:9100 - labels: - env: cloudalchemy - docker: - - targets: - - demo.cloudalchemy.org:8080 - - influx.cloudalchemy.org:8080 - labels: - env: cloudalchemy - prometheus_scrape_configs: - - job_name: "prometheus" - metrics_path: "{{ prometheus_metrics_path }}" - static_configs: - - targets: - - "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:9090" - - job_name: "node" - file_sd_configs: - - files: - - "{{ prometheus_config_dir }}/file_sd/node.yml" - - job_name: "docker" - file_sd_configs: - - files: - - "{{ prometheus_config_dir }}/file_sd/docker.yml" - - job_name: 'blackbox' - metrics_path: /probe - params: - module: [http_2xx] - static_configs: - - targets: - - http://demo.cloudalchemy.org:9100 - - http://influx.cloudalchemy.org:9100 - 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 # Blackbox exporter. diff --git a/roles/prometheus/molecule/alternative/prepare.yml b/roles/prometheus/molecule/alternative/prepare.yml deleted file mode 100644 index 41962804..00000000 --- a/roles/prometheus/molecule/alternative/prepare.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Prepare - hosts: localhost - gather_facts: false - vars: - # Version seeds to be specified here as molecule doesn't have access to ansible_version at this stage - version: 2.14.0 - tasks: - - name: download prometheus binary to local folder - become: false - get_url: - url: "https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz" - dest: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" - register: _download_archive - until: _download_archive is succeeded - retries: 5 - delay: 2 - run_once: true - check_mode: false - - - name: unpack prometheus binaries - become: false - unarchive: - src: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz" - dest: "/tmp" - creates: "/tmp/prometheus-{{ version }}.linux-amd64/prometheus" - run_once: true - check_mode: false - - - name: link to prometheus binaries directory - become: false - file: - src: "/tmp/prometheus-{{ version }}.linux-amd64" - dest: "/tmp/prometheus-linux-amd64" - state: link - run_once: true - check_mode: false diff --git a/roles/prometheus/molecule/alternative/tests/test_alternative.py b/roles/prometheus/molecule/alternative/tests/test_alternative.py deleted file mode 100644 index 8ef6d2ad..00000000 --- a/roles/prometheus/molecule/alternative/tests/test_alternative.py +++ /dev/null @@ -1,44 +0,0 @@ -import pytest -import os -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -@pytest.mark.parametrize("dirs", [ - "/opt/prom/etc", - "/opt/prom/etc/rules", - "/opt/prom/etc/file_sd", - "/opt/prom/lib" -]) -def test_directories(host, dirs): - d = host.file(dirs) - assert d.is_directory - assert d.exists - - -@pytest.mark.parametrize("files", [ - "/opt/prom/etc/prometheus.yml", - "/opt/prom/etc/rules/ansible_managed.rules", - "/opt/prom/etc/file_sd/node.yml", - "/opt/prom/etc/file_sd/docker.yml", - "/etc/systemd/system/prometheus.service", - "/usr/local/bin/prometheus", - "/usr/local/bin/promtool" -]) -def test_files(host, files): - f = host.file(files) - assert f.exists - assert f.is_file - - -def test_service(host): - s = host.service("prometheus") - # assert s.is_enabled - assert s.is_running - - -def test_socket(host): - s = host.socket("tcp://127.0.0.1:9090") - assert s.is_listening diff --git a/roles/prometheus/molecule/default/molecule.yml b/roles/prometheus/molecule/default/molecule.yml deleted file mode 100644 index 8937ee83..00000000 --- a/roles/prometheus/molecule/default/molecule.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -# lint: | -# set -e -# yamllint . -# ansible-lint -# flake8 -platforms: - - name: bionic - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: xenial - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: stretch - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:debian-9 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: buster - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:debian-10 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: centos7 - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:centos-7 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: centos8 - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:centos-8 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - groups: - - python3 - - name: fedora - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:fedora-30 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - groups: - - python3 -provisioner: - name: ansible - playbooks: - prepare: prepare.yml - converge: playbook.yml - inventory: - group_vars: - python3: - ansible_python_interpreter: /usr/bin/python3 -verifier: - name: testinfra diff --git a/roles/prometheus/molecule/default/playbook.yml b/roles/prometheus/molecule/default/playbook.yml deleted file mode 100644 index 688fb1dc..00000000 --- a/roles/prometheus/molecule/default/playbook.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Run role - hosts: all - any_errors_fatal: true - roles: - - ansible-prometheus diff --git a/roles/prometheus/molecule/default/prepare.yml b/roles/prometheus/molecule/default/prepare.yml deleted file mode 100644 index 5358b3bd..00000000 --- a/roles/prometheus/molecule/default/prepare.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: false - tasks: [] diff --git a/roles/prometheus/molecule/default/tests/test_default.py b/roles/prometheus/molecule/default/tests/test_default.py deleted file mode 100644 index 3a2e5b48..00000000 --- a/roles/prometheus/molecule/default/tests/test_default.py +++ /dev/null @@ -1,71 +0,0 @@ -import pytest -import os -import yaml -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -@pytest.fixture() -def AnsibleDefaults(): - with open("defaults/main.yml", 'r') as stream: - return yaml.safe_load(stream) - - -@pytest.mark.parametrize("dirs", [ - "/etc/prometheus", - "/etc/prometheus/console_libraries", - "/etc/prometheus/consoles", - "/etc/prometheus/rules", - "/etc/prometheus/file_sd", - "/var/lib/prometheus" -]) -def test_directories(host, dirs): - d = host.file(dirs) - assert d.is_directory - assert d.exists - - -@pytest.mark.parametrize("files", [ - "/etc/prometheus/prometheus.yml", - "/etc/prometheus/console_libraries/prom.lib", - "/etc/prometheus/consoles/prometheus.html", - "/etc/systemd/system/prometheus.service", - "/usr/local/bin/prometheus", - "/usr/local/bin/promtool" -]) -def test_files(host, files): - f = host.file(files) - assert f.exists - assert f.is_file - - -@pytest.mark.parametrize("files", [ - "/etc/prometheus/rules/ansible_managed.rules" -]) -def test_absent(host, files): - f = host.file(files) - assert f.exists - - -def test_user(host): - assert host.group("prometheus").exists - assert host.user("prometheus").exists - - -def test_service(host): - s = host.service("prometheus") - # assert s.is_enabled - assert s.is_running - - -def test_socket(host): - s = host.socket("tcp://0.0.0.0:9090") - assert s.is_listening - - -def test_version(host, AnsibleDefaults): - version = os.getenv('PROMETHEUS', AnsibleDefaults['prometheus_version']) - out = host.run("/usr/local/bin/prometheus --version").stderr - assert "prometheus, version " + version in out diff --git a/roles/prometheus/molecule/latest/molecule.yml b/roles/prometheus/molecule/latest/molecule.yml deleted file mode 100644 index a5a9cebb..00000000 --- a/roles/prometheus/molecule/latest/molecule.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -platforms: - - name: buster - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:debian-10 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - name: fedora - pre_build_image: true - image: quay.io/paulfantom/molecule-systemd:fedora-30 - docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" - privileged: true - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - groups: - - python3 -provisioner: - name: ansible - playbooks: - create: ../default/create.yml - prepare: ../default/prepare.yml - converge: playbook.yml - destroy: ../default/destroy.yml - inventory: - group_vars: - python3: - ansible_python_interpreter: /usr/bin/python3 -verifier: - name: testinfra diff --git a/roles/prometheus/molecule/latest/playbook.yml b/roles/prometheus/molecule/latest/playbook.yml deleted file mode 100644 index 9a7cc711..00000000 --- a/roles/prometheus/molecule/latest/playbook.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- name: Run role - hosts: all - any_errors_fatal: true - roles: - - ansible-prometheus - vars: - prometheus_version: latest diff --git a/roles/prometheus/molecule/latest/tests/test_alternative.py b/roles/prometheus/molecule/latest/tests/test_alternative.py deleted file mode 100644 index cbefab91..00000000 --- a/roles/prometheus/molecule/latest/tests/test_alternative.py +++ /dev/null @@ -1,28 +0,0 @@ -import pytest -import os -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') - - -@pytest.mark.parametrize("files", [ - "/etc/systemd/system/prometheus.service", - "/usr/local/bin/prometheus", - "/usr/local/bin/promtool" -]) -def test_files(host, files): - f = host.file(files) - assert f.exists - assert f.is_file - - -def test_service(host): - s = host.service("prometheus") - # assert s.is_enabled - assert s.is_running - - -def test_socket(host): - s = host.socket("tcp://0.0.0.0:9090") - assert s.is_listening diff --git a/roles/prometheus/tasks/configure.yml b/roles/prometheus/tasks/configure.yml deleted file mode 100644 index 8c76d332..00000000 --- a/roles/prometheus/tasks/configure.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- name: alerting rules file - template: - src: "alert.rules.j2" - dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules" - owner: root - group: prometheus - mode: 0640 - validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" - when: - - prometheus_alert_rules != [] - notify: - - reload prometheus - -- name: copy custom alerting rule files - copy: - src: "{{ item }}" - dest: "{{ prometheus_config_dir }}/rules/" - owner: root - group: prometheus - mode: 0640 - validate: "{{ _prometheus_binary_install_dir }}/promtool check rules %s" - with_fileglob: "{{ prometheus_alert_rules_files }}" - notify: - - reload prometheus - -- name: configure prometheus - template: - src: "{{ prometheus_config_file }}" - dest: "{{ prometheus_config_dir }}/prometheus.yml" - force: true - owner: root - group: prometheus - mode: 0640 - validate: "{{ _prometheus_binary_install_dir }}/promtool check config %s" - notify: - - reload prometheus - -- name: configure prometheus static targets - copy: - content: | - #jinja2: lstrip_blocks: True - {{ item.value | to_nice_yaml(indent=2) }} - dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml" - force: true - owner: root - group: prometheus - mode: 0640 - with_dict: "{{ prometheus_targets }}" - when: prometheus_targets != {} - -- name: copy prometheus custom static targets - copy: - src: "{{ item }}" - dest: "{{ prometheus_config_dir }}/file_sd/" - force: true - owner: root - group: prometheus - mode: 0640 - with_fileglob: "{{ prometheus_static_targets_files }}" diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml deleted file mode 100644 index e473d848..00000000 --- a/roles/prometheus/tasks/install.yml +++ /dev/null @@ -1,137 +0,0 @@ ---- -- name: create prometheus system group - group: - name: prometheus - system: true - state: present - -- name: create prometheus system user - user: - name: prometheus - system: true - shell: "/usr/sbin/nologin" - group: prometheus - createhome: false - home: "{{ prometheus_db_dir }}" - -- name: create prometheus data directory - file: - path: "{{ prometheus_db_dir }}" - state: directory - owner: prometheus - group: prometheus - mode: 0755 - -- name: create prometheus configuration directories - file: - path: "{{ item }}" - state: directory - owner: root - group: prometheus - mode: 0770 - with_items: - - "{{ prometheus_config_dir }}" - - "{{ prometheus_config_dir }}/rules" - - "{{ prometheus_config_dir }}/file_sd" - -- block: - - name: download prometheus binary to local folder - become: false - get_url: - url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" - dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" - checksum: "sha256:{{ __prometheus_checksum }}" - register: _download_archive - until: _download_archive is succeeded - retries: 5 - delay: 2 - # run_once: true # <-- this cannot be set due to multi-arch support - delegate_to: localhost - check_mode: false - - - name: unpack prometheus binaries - become: false - unarchive: - src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz" - dest: "/tmp" - creates: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/prometheus" - delegate_to: localhost - check_mode: false - - - name: propagate official prometheus and promtool binaries - copy: - src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}" - dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" - mode: 0755 - owner: root - group: root - with_items: - - prometheus - - promtool - notify: - - restart prometheus - - - name: propagate official console templates - copy: - src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}/" - dest: "{{ prometheus_config_dir }}/{{ item }}/" - mode: 0644 - owner: root - group: root - with_items: - - console_libraries - - consoles - notify: - - restart prometheus - when: - - prometheus_binary_local_dir | length == 0 - - not prometheus_skip_install - -- name: propagate locally distributed prometheus and promtool binaries - copy: - src: "{{ prometheus_binary_local_dir }}/{{ item }}" - dest: "{{ _prometheus_binary_install_dir }}/{{ item }}" - mode: 0755 - owner: root - group: root - with_items: - - prometheus - - promtool - when: - - prometheus_binary_local_dir | length > 0 - - not prometheus_skip_install - notify: - - restart prometheus - -- name: create systemd service unit - template: - src: prometheus.service.j2 - dest: /etc/systemd/system/prometheus.service - owner: root - group: root - mode: 0644 - notify: - - restart prometheus - -- name: Install SELinux dependencies - package: - name: "{{ item }}" - state: present - with_items: "{{ prometheus_selinux_packages }}" - register: _install_packages - until: _install_packages is succeeded - retries: 5 - delay: 2 - when: - - ansible_version.full is version('2.4', '>=') - - ansible_selinux.status == "enabled" - -- name: Allow prometheus to bind to port in SELinux - seport: - ports: "{{ prometheus_web_listen_address.split(':')[1] }}" - proto: tcp - setype: http_port_t - state: present - when: - - ansible_version.full is version('2.4', '>=') - - ansible_selinux.status == "enabled" diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml deleted file mode 100644 index ec32a72c..00000000 --- a/roles/prometheus/tasks/main.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Gather variables for each operating system - include_vars: "{{ item }}" - with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}.yml" - tags: - - prometheus_configure - - prometheus_install - - prometheus_run - -- include: preflight.yml - tags: - - prometheus_configure - - prometheus_install - - prometheus_run - -- include: install.yml - become: true - tags: - - prometheus_install - -- include: configure.yml - become: true - tags: - - prometheus_configure - -- name: ensure prometheus service is started and enabled - become: true - systemd: - daemon_reload: true - name: prometheus - state: started - enabled: true - tags: - - prometheus_run diff --git a/roles/prometheus/tasks/preflight.yml b/roles/prometheus/tasks/preflight.yml deleted file mode 100644 index 1582f8ac..00000000 --- a/roles/prometheus/tasks/preflight.yml +++ /dev/null @@ -1,114 +0,0 @@ ---- -- name: Assert usage of systemd as an init system - assert: - that: ansible_service_mgr == 'systemd' - msg: "This module only works with systemd" - -- name: Get systemd version - command: systemctl --version - changed_when: false - check_mode: false - register: __systemd_version - tags: - - skip_ansible_lint - -- name: Set systemd version fact - set_fact: - prometheus_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}" - -- name: Assert no duplicate config flags - assert: - that: - - prometheus_config_flags_extra['config.file'] is not defined - - prometheus_config_flags_extra['storage.tsdb.path'] is not defined - - prometheus_config_flags_extra['storage.local.path'] is not defined - - prometheus_config_flags_extra['web.listen-address'] is not defined - - prometheus_config_flags_extra['web.external-url'] is not defined - msg: "Detected duplicate configuration entry. Please check your ansible variables and role README.md." - -- name: Assert external_labels aren't configured twice - assert: - that: prometheus_global.external_labels is not defined - msg: "Use prometheus_external_labels to define external labels" - -- name: Set prometheus external metrics path - set_fact: - prometheus_metrics_path: "/{{ ( prometheus_web_external_url + '/metrics' ) | regex_replace('^(.*://)?(.*?)/') }}" - -- name: Fail when prometheus_config_flags_extra duplicates parameters set by other variables - fail: - msg: > - Whooops. You are duplicating configuration. Please look at your prometheus_config_flags_extra - and check against other variables in defaults/main.yml - with_items: - - 'storage.tsdb.retention' - - 'storage.tsdb.path' - - 'storage.local.retention' - - 'storage.local.path' - - 'config.file' - - 'web.listen-address' - - 'web.external-url' - when: item in prometheus_config_flags_extra.keys() - -- name: Get all file_sd files from scrape_configs - set_fact: - file_sd_files: "{{ prometheus_scrape_configs | json_query('[*][].file_sd_configs[*][].files[]') }}" - -- name: Fail when file_sd targets are not defined in scrape_configs - fail: - msg: > - Oh, snap! `{{ item.key }}` couldn't be found in your scrape configs. Please ensure you provided - all targets from prometheus_targets in prometheus_scrape_configs - when: not prometheus_config_dir + "/file_sd/" + item.key + ".yml" in file_sd_files - # when: not item | basename | splitext | difference(['.yml']) | join('') in prometheus_targets.keys() - with_dict: "{{ prometheus_targets }}" - -- name: Alert when prometheus_alertmanager_config is empty, but prometheus_alert_rules is specified - debug: - msg: > - No alertmanager configuration was specified. If you want your alerts to be sent make sure to - specify a prometheus_alertmanager_config in defaults/main.yml. - when: - - prometheus_alertmanager_config == [] - - prometheus_alert_rules != [] - -- block: - - name: Get latest release - uri: - url: "https://api.github.com/repos/prometheus/prometheus/releases/latest" - method: GET - return_content: true - status_code: 200 - body_format: json - validate_certs: false - user: "{{ lookup('env', 'GH_USER') | default(omit) }}" - password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}" - no_log: "{{ not lookup('env', 'ANSIBLE_DEBUG') | bool }}" - register: _latest_release - until: _latest_release.status == 200 - retries: 5 - - - name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}" - set_fact: - prometheus_version: "{{ _latest_release.json.tag_name[1:] }}" - when: - - prometheus_version == "latest" - - prometheus_binary_local_dir | length == 0 - - not prometheus_skip_install - -- block: - - name: "Get checksum list" - set_fact: - __prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', wantlist=True) | list }}" - run_once: true - - - name: "Get checksum for {{ go_arch }} architecture" - set_fact: - __prometheus_checksum: "{{ item.split(' ')[0] }}" - with_items: "{{ __prometheus_checksums }}" - when: - - "('linux-' + go_arch + '.tar.gz') in item" - delegate_to: localhost - when: - - prometheus_binary_local_dir | length == 0 - - not prometheus_skip_install diff --git a/roles/prometheus/templates/alert.rules.j2 b/roles/prometheus/templates/alert.rules.j2 deleted file mode 100644 index 8498cf85..00000000 --- a/roles/prometheus/templates/alert.rules.j2 +++ /dev/null @@ -1,6 +0,0 @@ -{{ ansible_managed | comment }} - -groups: -- name: ansible managed alert rules - rules: - {{ prometheus_alert_rules | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/templates/prometheus.service.j2 b/roles/prometheus/templates/prometheus.service.j2 deleted file mode 100644 index 0348b9fe..00000000 --- a/roles/prometheus/templates/prometheus.service.j2 +++ /dev/null @@ -1,66 +0,0 @@ -{{ ansible_managed | comment }} - -[Unit] -Description=Prometheus -After=network-online.target -Requires=local-fs.target -After=local-fs.target - -[Service] -Type=simple -Environment="GOMAXPROCS={{ ansible_processor_vcpus|default(ansible_processor_count) }}" -User=prometheus -Group=prometheus -ExecReload=/bin/kill -HUP $MAINPID -ExecStart={{ _prometheus_binary_install_dir }}/prometheus \ - --config.file={{ prometheus_config_dir }}/prometheus.yml \ - --storage.tsdb.path={{ prometheus_db_dir }} \ -{% if prometheus_version is version('2.7.0', '>=') %} - --storage.tsdb.retention.time={{ prometheus_storage_retention }} \ - --storage.tsdb.retention.size={{ prometheus_storage_retention_size }} \ -{% else %} - --storage.tsdb.retention={{ prometheus_storage_retention }} \ -{% endif %} - --web.console.libraries={{ prometheus_config_dir }}/console_libraries \ - --web.console.templates={{ prometheus_config_dir }}/consoles \ - --web.listen-address={{ prometheus_web_listen_address }} \ - --web.external-url={{ prometheus_web_external_url }}{% for flag, flag_value in prometheus_config_flags_extra.items() %}\ - --{{ flag }}{% if flag_value %}={{ flag_value }}{% endif %} {% endfor %} - -CapabilityBoundingSet=CAP_SET_UID -LimitNOFILE=65000 -LockPersonality=true -NoNewPrivileges=true -MemoryDenyWriteExecute=true -PrivateDevices=true -PrivateTmp=true -ProtectHome=true -RemoveIPC=true -RestrictSUIDSGID=true -#SystemCallFilter=@signal @timer - -{% if prometheus_systemd_version | int >= 231 %} -ReadWritePaths={{ prometheus_db_dir }} -{% else %} -ReadWriteDirectories={{ prometheus_db_dir }} -{% endif %} - -{% if prometheus_systemd_version | int >= 232 %} -PrivateUsers=true -ProtectControlGroups=true -ProtectKernelModules=true -ProtectKernelTunables=true -ProtectSystem=strict -{% else %} -ProtectSystem=full -{% endif %} - -{% if http_proxy is defined %} -Environment="HTTP_PROXY={{ http_proxy }}"{% if https_proxy is defined %} "HTTPS_PROXY={{ https_proxy }}{% endif %}" -{% endif %} - -SyslogIdentifier=prometheus -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 deleted file mode 100644 index d16a1843..00000000 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ /dev/null @@ -1,34 +0,0 @@ -#jinja2: trim_blocks: True, lstrip_blocks: True -{{ ansible_managed | comment }} -# http://prometheus.io/docs/operating/configuration/ - -global: - {{ prometheus_global | to_nice_yaml(indent=2) | indent(2, False) }} - external_labels: - {{ prometheus_external_labels | to_nice_yaml(indent=2) | indent(4, False) }} - -{% if prometheus_remote_write != [] %} -remote_write: - {{ prometheus_remote_write | to_nice_yaml(indent=2) | indent(2, False) }} -{% endif %} - -{% if prometheus_remote_read != [] %} -remote_read: - {{ prometheus_remote_read | to_nice_yaml(indent=2) | indent(2, False) }} -{% endif %} - -rule_files: - - {{ prometheus_config_dir }}/rules/*.rules - -{% if prometheus_alertmanager_config | length > 0 %} -alerting: - alertmanagers: - {{ prometheus_alertmanager_config | to_nice_yaml(indent=2) | indent(2,False) }} - {% if prometheus_alert_relabel_configs | length > 0 %} - alert_relabel_configs: - {{ prometheus_alert_relabel_configs | to_nice_yaml(indent=2) | indent(2,False) }} - {% endif %} -{% endif %} - -scrape_configs: - {{ prometheus_scrape_configs | to_nice_yaml(indent=2) | indent(2,False) }} diff --git a/roles/prometheus/test-requirements.txt b/roles/prometheus/test-requirements.txt deleted file mode 100644 index 1b6e9a96..00000000 --- a/roles/prometheus/test-requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -molecule>=3.0.0 -molecule-docker -docker -ansible-lint>=3.4.0 -testinfra>=1.7.0 -jmespath -selinux -passlib diff --git a/roles/prometheus/vars/centos-8.yml b/roles/prometheus/vars/centos-8.yml deleted file mode 100644 index 3fc18d81..00000000 --- a/roles/prometheus/vars/centos-8.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - python3-libselinux - - python3-policycoreutils diff --git a/roles/prometheus/vars/centos.yml b/roles/prometheus/vars/centos.yml deleted file mode 100644 index ea3dea19..00000000 --- a/roles/prometheus/vars/centos.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - libselinux-python - - policycoreutils-python diff --git a/roles/prometheus/vars/debian.yml b/roles/prometheus/vars/debian.yml deleted file mode 100644 index d109c39f..00000000 --- a/roles/prometheus/vars/debian.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - python-selinux - - policycoreutils diff --git a/roles/prometheus/vars/fedora.yml b/roles/prometheus/vars/fedora.yml deleted file mode 100644 index 3fc18d81..00000000 --- a/roles/prometheus/vars/fedora.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - python3-libselinux - - python3-policycoreutils diff --git a/roles/prometheus/vars/main.yml b/roles/prometheus/vars/main.yml deleted file mode 100644 index 091379fd..00000000 --- a/roles/prometheus/vars/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -go_arch_map: - i386: '386' - x86_64: 'amd64' - aarch64: 'arm64' - armv7l: 'armv7' - armv6l: 'armv6' - -go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" -_prometheus_binary_install_dir: '/usr/local/bin' diff --git a/roles/prometheus/vars/redhat-8.yml b/roles/prometheus/vars/redhat-8.yml deleted file mode 100644 index 3fc18d81..00000000 --- a/roles/prometheus/vars/redhat-8.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - python3-libselinux - - python3-policycoreutils diff --git a/roles/prometheus/vars/redhat.yml b/roles/prometheus/vars/redhat.yml deleted file mode 100644 index ea3dea19..00000000 --- a/roles/prometheus/vars/redhat.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -prometheus_selinux_packages: - - libselinux-python - - policycoreutils-python From 020916e170b450d6d6d543cf4c5f6017ffd47af6 Mon Sep 17 00:00:00 2001 From: tingwei Date: Mon, 11 Nov 2024 10:13:43 +0800 Subject: [PATCH 4/4] remove prometheus module --- modules/prometheus/.tflint.hcl | 3 - modules/prometheus/INOUT.md | 62 ----- modules/prometheus/README.md | 107 -------- modules/prometheus/aws_auth.tf | 20 -- modules/prometheus/consul.tf | 43 --- modules/prometheus/curator.tf | 9 - modules/prometheus/example.tfvars | 5 - modules/prometheus/files/user_data.sh | 49 ---- modules/prometheus/main.tf | 135 ---------- modules/prometheus/outputs.tf | 14 - modules/prometheus/packer/ami/configure.sh | 252 ------------------ modules/prometheus/packer/ami/packer.json | 117 -------- modules/prometheus/packer/ami/site.yml | 143 ---------- .../prometheus/packer/ami/td-agent-vars.yml | 32 --- modules/prometheus/packer/data/packer.json | 63 ----- modules/prometheus/td_agent.tf | 9 - modules/prometheus/traefik.tf | 30 --- modules/prometheus/variables.tf | 229 ---------------- modules/prometheus/vault_ssh.tf | 24 -- modules/prometheus/versions.tf | 16 -- 20 files changed, 1362 deletions(-) delete mode 100644 modules/prometheus/.tflint.hcl delete mode 100644 modules/prometheus/INOUT.md delete mode 100644 modules/prometheus/README.md delete mode 100644 modules/prometheus/aws_auth.tf delete mode 100644 modules/prometheus/consul.tf delete mode 100644 modules/prometheus/curator.tf delete mode 100644 modules/prometheus/example.tfvars delete mode 100644 modules/prometheus/files/user_data.sh delete mode 100644 modules/prometheus/main.tf delete mode 100644 modules/prometheus/outputs.tf delete mode 100644 modules/prometheus/packer/ami/configure.sh delete mode 100644 modules/prometheus/packer/ami/packer.json delete mode 100644 modules/prometheus/packer/ami/site.yml delete mode 100644 modules/prometheus/packer/ami/td-agent-vars.yml delete mode 100644 modules/prometheus/packer/data/packer.json delete mode 100644 modules/prometheus/td_agent.tf delete mode 100644 modules/prometheus/traefik.tf delete mode 100644 modules/prometheus/variables.tf delete mode 100644 modules/prometheus/vault_ssh.tf delete mode 100644 modules/prometheus/versions.tf diff --git a/modules/prometheus/.tflint.hcl b/modules/prometheus/.tflint.hcl deleted file mode 100644 index c94d47ad..00000000 --- a/modules/prometheus/.tflint.hcl +++ /dev/null @@ -1,3 +0,0 @@ -config { - varfile = ["example.tfvars"] -} diff --git a/modules/prometheus/INOUT.md b/modules/prometheus/INOUT.md deleted file mode 100644 index 386a3e39..00000000 --- a/modules/prometheus/INOUT.md +++ /dev/null @@ -1,62 +0,0 @@ -## Providers - -| Name | Version | -|------|---------| -| aws | >= 2.42, < 4.0.0 | -| consul | >= 2.5 | -| template | >= 2.0 | -| vault | n/a | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:-----:| -| additional\_cidr\_blocks | Additional CIDR blocks other than the VPC CIDR block thatn can access the Prometheus server | `list(string)` | `[]` | no | -| allowed\_ssh\_cidr\_blocks | List of allowed CIDR blocks to allow SSH access | `list(string)` | `[]` | no | -| ami\_id | AMI ID for Prometheus Server | `any` | n/a | yes | -| associate\_public\_ip\_address | Associate a public IP address for instance | `bool` | `false` | no | -| aws\_auth\_enabled | Enable AWS Authentication | `bool` | `false` | no | -| aws\_auth\_path | Path to the Vault AWS Authentication backend | `string` | `"aws"` | no | -| aws\_auth\_period\_minutes | Period, in minutes, that the Vault token issued will live for | `string` | `"60"` | no | -| aws\_auth\_policies | List of Vault policies to assign to the tokens issued by the AWS authentication backend | `list(string)` | `[]` | no | -| aws\_auth\_vault\_role | Name of the role in the AWS Authentication backend to create | `string` | `"prometheus"` | no | -| consul\_cluster\_tag\_key | Key that Consul Server Instances are tagged with for discovery | `string` | `"consul-servers"` | no | -| consul\_cluster\_tag\_value | Value that Consul Server Instances are tagged with for discovery | `string` | `"consul"` | no | -| consul\_key\_prefix | Path prefix to the key in Consul to set for the `core` module to know that this module has
been applied. If you change this, you have to update the
`integration_consul_prefix` variable in the core module as well. | `string` | `"terraform/"` | no | -| consul\_security\_group\_id | Security Group ID for Consul servers | `any` | n/a | yes | -| curator\_age | Age in days to retain indices | `string` | `"90"` | no | -| curator\_enable | Enable Curator integration for Prometheus | `bool` | `false` | no | -| curator\_prefix | Elasticsearch prefix for Curator logs | `string` | `"services.prometheus"` | no | -| data\_device\_name | Path of the EBS device that is mounted | `string` | `"/dev/nvme1n1"` | no | -| data\_volume\_id | EBS Volume ID for Prometheus Data Storage | `any` | n/a | yes | -| data\_volume\_mount | Data volume mount device name | `string` | `"/dev/sdf"` | no | -| instance\_type | Type of instance to deploy | `string` | `"t2.micro"` | no | -| name | Base name for resources | `string` | `"prometheus"` | no | -| prometheus\_client\_service | Name of the Prometheus Client services to scrape | `string` | `"prometheus-client"` | no | -| prometheus\_db\_dir | Path where the data for Prometheus will be stored. This will be where the EBS volume where data is persisted will be mounted. | `string` | `"/mnt/data"` | no | -| prometheus\_port | Port at which the server will be listening to. | `string` | `"9090"` | no | -| prometheus\_service | Name of Prometheus server service to register in Consul. | `string` | `"prometheus"` | no | -| root\_volume\_size | Size of the Prometheus server root volume in GB | `number` | `50` | no | -| server\_type | Server type for the various types of modules integration | `string` | `"prometheus"` | no | -| ssh\_key\_name | Name of SSH key to assign to the instance | `any` | n/a | yes | -| subnet\_id | Subnet ID to deploy the instance to | `any` | n/a | yes | -| tags | Tags to apply to resources | `map` |
{
"Terraform": "true"
}
| no | -| td\_agent\_enabled | Enable td-agent integration. You will still need to provide the appropriate configuration file for td-agent during the AMI building process. | `bool` | `false` | no | -| traefik\_enabled | Enable Traefik Integration | `bool` | `false` | no | -| traefik\_entrypoints | List of entrypoints for Traefik | `list` |
[
"internal"
]
| no | -| traefik\_fqdns | List of FQDNs for Traefik to listen to. You have to create the DNS records separately. | `list(string)` | `[]` | no | -| vault\_ssh\_enabled | Enable Vault SSH integration | `bool` | `false` | no | -| vault\_ssh\_max\_ttl | Max TTL for certificate renewal | `number` | `86400` | no | -| vault\_ssh\_path | Path to mount the SSH secrets engine | `string` | `"ssh_prometheus"` | no | -| vault\_ssh\_role\_name | Role name for the Vault SSH secrets engine | `string` | `"default"` | no | -| vault\_ssh\_ttl | TTL for the Vault SSH certificate in seconds | `number` | `300` | no | -| vault\_ssh\_user | Username to allow SSH access | `string` | `"ubuntu"` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| instance\_id | Instance ID for the server | -| instance\_private\_ip | Private IP address for the server | -| security\_group\_id | Security Group ID for the instance | - diff --git a/modules/prometheus/README.md b/modules/prometheus/README.md deleted file mode 100644 index 2563c236..00000000 --- a/modules/prometheus/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# Prometheus Server - -This module sets up a Prometheus server with tight integrations with the other modules in this -repository. - -## Packer Template - -### Instance AMI - -You will have to build an AMI with the [Packer template](packer/packer.json) provided. -See https://github.com/cloudalchemy/ansible-prometheus/blob/3b866fd50d4b13c7ee4d7f45f7308354acbe3036/README.md for build instructions. -If you are using Mac as the deployer host, you may encounter the following issue: https://github.com/rbenv/ruby-build/issues/1385 - -```bash -packer build \ - -var-file "your_vars.json" \ - packer/ami/packer.json -``` - -Ansible will be used to provision the AMI. - -### Data Volume Snapshot - -You will need to use Packer to build a __one off__ data volume to hold your Prometheus data. You -will then need to provide the EBS volume ID to the Terraform module. - -**Make sure you create the volume in the same availability zone as the instance you are going to run.** - -```bash -packer build \ - -var-file "your_vars.json" \ - packer/data/packer.json -``` - -## Persistence - -By default, Prometheus will be configured to write to `/mnt/data`, which the Terraform module will -create as a separate EBS volume that will be mounted onto the Prometheus EC2 instance. This will -ensure that the data from Prometheus is never lost when respawning the EC2 instance. - -## Scraping - -Prometheus will be configured to scrape targets from -[Consul](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#consul_sd_config). - -Prometheus will be configured will scrape from targets in the `prometheus-client` service by default -on the path `/metrics` by default. The port of the Prometheus client will be the port that is -reported by the service. - -In addition, you can add the following [tags](https://www.consul.io/docs/agent/services.html) in -the form of `=` to change the behaviour for scraping: - -- `prometheus_path`: Change the path for scraping to anything else other than `/metrics`. -- `prometheus_disable`: Set this to `true` to temporarily stop scraping this target - -Up to 5 other keys that are prefixed with `prometheus_tag_` will be added as labels for the target -with their prefixes removed. To allow for more tags, modify the the -[Ansible playbook](packer/ami/site.yml) with more relabel actions. This is a limitation of -Prometheus. - -## Important Variables - -The following variables, available both in the Packer template and Terraform module unless otherwise -stated, are the more "important" variables that **must be equal** in both places for Prometheus to -work properly. - -- `prometheus_client_service`: Name of the Prometheus clients to scrape from. Defaults to `prometheus-client` -- `prometheus_db_dir`: Path where the data for Prometheus will be stored. This will be where the EBS volume where data is persisted will be mounted. Defaults to `/mnt/data`. -- `prometheus_port`: Port at which the server will be listening to. Defaults to `9090`. - -## Integration with other modules - -### Traefik - -Automatic reverse proxy via Traefik can be enabled with the appropriate variables set. - -### AWS Authentication - -An AWS authentication role can be automatically created. - -### Vault SSH - -Access via SSH with Vault can be automatically configured. - -### `td-agent` - -If you would like to configure `td-agent` to automatically ship logs to your fluentd server, you -will have to provide a configuration file for `td-agent`. - -You can use the recommended default template and variables by setting the following variables for -the Packer template: - -- `td_agent_config_file`: Set this to `../td-agent/config/template/td-agent.conf` -- `td_agent_config_vars_file`: Set this to `packer/td-agent-vars.yml`. - -For example, add the following arguments to `packer build`: - -```bash - --var "td_agent_config_file=$(pwd)/../td-agent/config/template/td-agent.conf" \ - --var "td_agent_config_vars_file=$(pwd)/packer/td-agent-vars.yml" -``` - -Refer to the module documentation for more details. - -## Inputs and Outputs - -Refer to [INOUT.md](INOUT.md) diff --git a/modules/prometheus/aws_auth.tf b/modules/prometheus/aws_auth.tf deleted file mode 100644 index 4fb5744c..00000000 --- a/modules/prometheus/aws_auth.tf +++ /dev/null @@ -1,20 +0,0 @@ -resource "vault_aws_auth_backend_role" "prometheus" { - count = var.aws_auth_enabled ? 1 : 0 - - backend = var.aws_auth_path - role = var.aws_auth_vault_role - auth_type = "ec2" - bound_iam_role_arns = [aws_iam_role.prometheus.arn] - token_policies = var.aws_auth_policies - token_period = var.aws_auth_period_minutes -} - -resource "consul_keys" "aws_auth" { - count = var.aws_auth_enabled ? 1 : 0 - - key { - path = "${var.consul_key_prefix}aws-auth/roles/${var.server_type}" - value = var.aws_auth_vault_role - delete = true - } -} diff --git a/modules/prometheus/consul.tf b/modules/prometheus/consul.tf deleted file mode 100644 index 59127d6b..00000000 --- a/modules/prometheus/consul.tf +++ /dev/null @@ -1,43 +0,0 @@ -locals { - consul_prefix = "${var.consul_key_prefix}prometheus/" -} - -resource "consul_keys" "service_name" { - key { - path = "${local.consul_prefix}service_name" - value = var.prometheus_service - delete = true - } -} - -resource "consul_keys" "client_service" { - key { - path = "${local.consul_prefix}client_service" - value = var.prometheus_client_service - delete = true - } -} - -resource "consul_keys" "db_dir" { - key { - path = "${local.consul_prefix}db_dir" - value = var.prometheus_db_dir - delete = true - } -} - -resource "consul_keys" "port" { - key { - path = "${local.consul_prefix}port" - value = var.prometheus_port - delete = true - } -} - -resource "consul_keys" "data_device_name" { - key { - path = "${local.consul_prefix}data_device_name" - value = var.data_device_name - delete = true - } -} diff --git a/modules/prometheus/curator.tf b/modules/prometheus/curator.tf deleted file mode 100644 index f473d512..00000000 --- a/modules/prometheus/curator.tf +++ /dev/null @@ -1,9 +0,0 @@ -module "curator" { - source = "../curator/action" - - key = "prometheus" - disable = var.curator_enable ? "false" : "true" - age = var.curator_age - prefix = var.curator_prefix - consul_key_prefix = var.consul_key_prefix -} diff --git a/modules/prometheus/example.tfvars b/modules/prometheus/example.tfvars deleted file mode 100644 index 2e15094b..00000000 --- a/modules/prometheus/example.tfvars +++ /dev/null @@ -1,5 +0,0 @@ -ami_id = "xxx" -ssh_key_name = "xxx" -subnet_id = "xxx" -consul_security_group_id = "xxx" -data_volume_id = "xxx" diff --git a/modules/prometheus/files/user_data.sh b/modules/prometheus/files/user_data.sh deleted file mode 100644 index b26c860b..00000000 --- a/modules/prometheus/files/user_data.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# Avoid Terraform template by either using double dollar signs, or not using curly braces -readonly service_type="${service_type}" -readonly marker_path="/etc/user-data-marker" - -# Send the log output from this script to user-data.log, syslog, and the console -# From: https://alestic.com/2010/12/ec2-user-data-output/ -exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 - -# These variables are passed in via Terraform template interplation -/opt/consul/bin/run-consul \ - --client \ - --cluster-tag-key "${cluster_tag_key}" \ - --cluster-tag-value "${cluster_tag_value}" - -# Post startup Configuration -/opt/consul/bin/post-configure \ - --client \ - --initialisation-marker-path "$marker_path" \ - --consul-prefix "${consul_prefix}" - -# Configure and run consul-template -/opt/consul-template/bin/run-consul-template \ - --server-type "$service_type" \ - --dedup-enable \ - --syslog-enable \ - --consul-prefix "${consul_prefix}" - -# Configure Consul for Prometheus Service registration -/opt/prometheus --server-type "$service_type" \ - --consul-prefix "${consul_prefix}" - -/opt/vault-ssh \ - --consul-prefix "${consul_prefix}" \ - --type "$service_type" - -/opt/run-td-agent \ - --consul-prefix "${consul_prefix}" \ - --type "$service_type" - -/opt/run-telegraf \ - --consul-prefix "${consul_prefix}" \ - --type "$service_type" - -# Touch the marker file to indicate completion -touch "$marker_path" diff --git a/modules/prometheus/main.tf b/modules/prometheus/main.tf deleted file mode 100644 index 1cd3b772..00000000 --- a/modules/prometheus/main.tf +++ /dev/null @@ -1,135 +0,0 @@ -data "aws_subnet" "selected" { - id = var.subnet_id -} - -data "aws_vpc" "selected" { - id = data.aws_subnet.selected.vpc_id -} - -resource "aws_instance" "prometheus" { - ami = var.ami_id - instance_type = var.instance_type - key_name = var.ssh_key_name - subnet_id = var.subnet_id - - user_data = data.template_file.user_data.rendered - - associate_public_ip_address = var.associate_public_ip_address - vpc_security_group_ids = [aws_security_group.prometheus.id] - iam_instance_profile = aws_iam_instance_profile.prometheus.name - tags = merge(var.tags, { Name = var.name }) - volume_tags = merge(var.tags, { Name = var.name }) - - root_block_device { - volume_type = "gp2" - volume_size = var.root_volume_size - } -} - -resource "aws_volume_attachment" "data" { - device_name = var.data_volume_mount - volume_id = var.data_volume_id - instance_id = aws_instance.prometheus.id - - skip_destroy = true -} - -data "template_file" "user_data" { - template = file("${path.module}/files/user_data.sh") - - vars = { - service_type = var.server_type - - cluster_tag_key = var.consul_cluster_tag_key - cluster_tag_value = var.consul_cluster_tag_value - consul_prefix = var.consul_key_prefix - } -} - -resource "aws_iam_instance_profile" "prometheus" { - name = var.name - role = aws_iam_role.prometheus.name -} - -resource "aws_iam_role" "prometheus" { - name = var.name - assume_role_policy = data.aws_iam_policy_document.assume_role.json - description = "IAM Role for Prometheus server" -} - -data "aws_iam_policy_document" "assume_role" { - statement { - effect = "Allow" - actions = ["sts:AssumeRole"] - - principals { - type = "Service" - identifiers = ["ec2.amazonaws.com"] - } - } -} - -# --------------------------------------------------------------------------------------------------------------------- -# ATTACH IAM POLICIES FOR CONSUL -# To allow our client Nodes to automatically discover the Consul servers, we need to give them the IAM permissions from -# the Consul AWS Module's consul-iam-policies module. -# --------------------------------------------------------------------------------------------------------------------- -module "consul_iam_policies_clients" { - source = "github.com/hashicorp/terraform-aws-consul//modules/consul-iam-policies?ref=v0.8.3" - - iam_role_id = aws_iam_role.prometheus.id -} - -resource "aws_security_group" "prometheus" { - name = var.name - description = "Security group for Prometheus server" - vpc_id = data.aws_subnet.selected.vpc_id - - tags = merge(var.tags, { Name = var.name }) -} - -resource "aws_security_group_rule" "ssh_ingress" { - type = "ingress" - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = var.allowed_ssh_cidr_blocks - description = "SSH access to Prometheus server" - - security_group_id = aws_security_group.prometheus.id -} - -resource "aws_security_group_rule" "prometheus" { - type = "ingress" - from_port = var.prometheus_port - to_port = var.prometheus_port - protocol = "tcp" - cidr_blocks = concat(var.additional_cidr_blocks, [data.aws_vpc.selected.cidr_block]) - description = "Access to Prometheus server" - - security_group_id = aws_security_group.prometheus.id -} - -resource "aws_security_group_rule" "egress" { - type = "egress" - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - - security_group_id = aws_security_group.prometheus.id -} - -# --------------------------------------------------------------------------------------------------------------------- -# PERMIT CONSUL SPECIFIC TRAFFIC -# To allow the instance to communicate with other consul agents and participate in the LAN gossip, -# we open up the consul specific protocols and ports for consul traffic -# --------------------------------------------------------------------------------------------------------------------- - -module "consul_gossip" { - source = "github.com/hashicorp/terraform-aws-consul//modules/consul-client-security-group-rules?ref=v0.8.3" - - security_group_id = aws_security_group.prometheus.id - allowed_inbound_cidr_blocks = [data.aws_vpc.selected.cidr_block] - allowed_inbound_security_group_ids = [var.consul_security_group_id] -} diff --git a/modules/prometheus/outputs.tf b/modules/prometheus/outputs.tf deleted file mode 100644 index b669dc39..00000000 --- a/modules/prometheus/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "instance_id" { - description = "Instance ID for the server" - value = aws_instance.prometheus.id -} - -output "instance_private_ip" { - description = "Private IP address for the server" - value = aws_instance.prometheus.private_ip -} - -output "security_group_id" { - description = "Security Group ID for the instance" - value = aws_security_group.prometheus.id -} diff --git a/modules/prometheus/packer/ami/configure.sh b/modules/prometheus/packer/ami/configure.sh deleted file mode 100644 index 16cf388f..00000000 --- a/modules/prometheus/packer/ami/configure.sh +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -readonly SCRIPT_NAME="$(basename "$0")" - -readonly MAX_RETRIES=30 -readonly SLEEP_BETWEEN_RETRIES_SEC=10 - -function print_usage { - echo - echo "Usage: prometheus [OPTIONS]" - echo - echo "This script is used to configure a Prometheus instance." - echo - echo "Options:" - echo - echo -e " --server-type\t\tType of server for integrations with other modules. Optional. Defaults to 'prometheus'." - echo -e " --consul-config\t\tConsul configuration directory. Optional. Defaults to '/opt/consul/config'." - echo -e " --consul-prefix\t\tPath prefix in Consul KV store to query for integration status. Optional. Defaults to terraform/" -} - -function log { - local readonly level="$1" - local readonly message="$2" - local readonly timestamp=$(date +"%Y-%m-%d %H:%M:%S") - >&2 echo -e "${timestamp} [${level}] [$SCRIPT_NAME] ${message}" -} - -function log_info { - local readonly message="$1" - log "INFO" "${message}" -} - -function log_warn { - local readonly message="$1" - log "WARN" "${message}" -} - -function log_error { - local readonly message="$1" - log "ERROR" "${message}" -} - -function assert_not_empty { - local readonly arg_name="$1" - local readonly arg_value="$2" - - if [[ -z "${arg_value}" ]]; then - log_error "The value for '${arg_name}' cannot be empty" - print_usage - exit 1 - fi -} - -function assert_is_installed { - local readonly name="$1" - - if [[ ! $(command -v ${name}) ]]; then - log_error "The binary '${name}' is required by this script but is not installed or in the system's PATH." - exit 1 - fi -} - -# Based on: http://unix.stackexchange.com/a/7732/215969 -function get_owner_of_path { - local readonly path="$1" - ls -ld "$path" | awk '{print $3}' -} - -function wait_for_consul { - local consul_leader - - for (( i=1; i<="$MAX_RETRIES"; i++ )); do - consul_leader=$( - curl -sS http://localhost:8500/v1/status/leader 2> /dev/null || echo "failed" - ) - - if [[ "${consul_leader}" = "failed" ]]; then - log_warn "Failed to find Consul cluster leader. Will sleep for $SLEEP_BETWEEN_RETRIES_SEC seconds and try again." - sleep "$SLEEP_BETWEEN_RETRIES_SEC" - else - log_info "Found Consul leader at ${consul_leader}" - return - fi - done - - log_error "Failed to detect Consul agent after $MAX_RETRIES retries. Did you start a Consul agent before running the script?" - exit 1 -} - - -function consul_kv { - local readonly path="${1}" - local value - value=$(consul kv get "${path}") || exit $? - log_info "Consul KV Path ${path} = ${value}" - echo -n "${value}" -} - -function consul_kv_with_default { - local readonly path="${1}" - local readonly default="${2}" - local value - value=$(consul kv get "${path}" || echo -n "${default}") || exit $? - log_info "Consul KV Path ${path} = ${value}" - echo -n "${value}" -} - -# Based on: http://unix.stackexchange.com/a/7732/215969 -function get_owner_of_path { - local readonly path="$1" - ls -ld "$path" | awk '{print $3}' -} - -function generate_consul_config { - local readonly consul_prefix="${1}" - local readonly consul_config="${2}" - - local readonly consul_destination="${consul_config}/prometheus.hcl" - - local readonly prometheus_service=$(consul_kv "${consul_prefix}prometheus/service_name") - local readonly prometheus_port=$(consul_kv "${consul_prefix}prometheus/port") - - local readonly traefik_enabled=$(consul_kv_with_default "${consul_prefix}prometheus/traefik/enabled" "no") - - local traefik_tags="" - - if [[ "$traefik_enabled" == "yes" ]]; then - local readonly traefik_fqdns=$(consul_kv "${consul_prefix}prometheus/traefik/fqdns") - local readonly traefik_entrypoints=$(consul_kv "${consul_prefix}prometheus/traefik/entrypoints") - - traefik_tags=$(cat < "${consul_destination}" - local readonly consul_owner=$(get_owner_of_path "${consul_config}") - chown "${consul_owner}:${consul_owner}" "${consul_destination}" - - systemctl kill -s SIGHUP consul -} - -function mount_ebs { - local readonly data_device_name="${1}" - local readonly db_dir="${2}" - - until ls "${data_device_name}"; do - log_info "Waiting for data device ${data_device_name} to be mounted" - sleep 5 - done - - log_info "Mounting data volume" - mkdir -p "${db_dir}" - mount "${data_device_name}" "${db_dir}" - - local readonly uuid="$(blkid -s UUID -o value "${data_device_name}")" - echo "" >> /etc/fstab - echo "UUID=${uuid} ${db_dir} ext4 defaults,nofail" >> /etc/fstab - # Safety Check - mount -a - - chown -R prometheus:prometheus "${db_dir}" -} -function main { - local consul_config="/opt/consul/config" - local server_type="prometheus" - local consul_prefix="terraform/" - local all_args=() - - while [[ $# > 0 ]]; do - local key="$1" - - case "$key" in - --consul-config) - assert_not_empty "$key" "$2" - consul_config="$2" - shift - ;; - --server-type) - assert_not_empty "$key" "$2" - server_type="$2" - shift - ;; - --consul-prefix) - assert_not_empty "$key" "$2" - consul_prefix="$2" - shift - ;; - --help) - print_usage - exit - ;; - *) - log_error "Unrecognized argument: $key" - print_usage - exit 1 - ;; - esac - - shift - done - - assert_is_installed "curl" - assert_is_installed "consul" - - wait_for_consul - - generate_consul_config "${consul_prefix}" "${consul_config}" - - local readonly data_device_name=$(consul_kv "${consul_prefix}prometheus/data_device_name") - local readonly db_dir=$(consul_kv "${consul_prefix}prometheus/db_dir") - mount_ebs "$data_device_name" "$db_dir" - - systemctl enable prometheus - systemctl start prometheus -} - -main "$@" diff --git a/modules/prometheus/packer/ami/packer.json b/modules/prometheus/packer/ami/packer.json deleted file mode 100644 index 253051c9..00000000 --- a/modules/prometheus/packer/ami/packer.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "min_packer_version": "1.1.2", - "variables": { - "additional_ntp_servers": "[\"169.254.169.123\"]", - "ami_base_name": "prometheus", - "aws_region": "ap-southeast-1", - "subnet_id": "", - "temporary_security_group_source_cidrs": "0.0.0.0/0", - "associate_public_ip_address": "true", - "ssh_interface": "", - "consul_module_repo": "https://github.com/hashicorp/terraform-aws-consul.git", - "consul_module_version": "v0.3.5", - "consul_version": "1.4.0", - "consul_enable_syslog": "true", - "td_agent_config_file": "", - "td_agent_config_vars_file": "", - "td_agent_config_app_vars_file": "", - "ca_certificate": "", - "consul_host": "", - "consul_port": "443", - "consul_scheme": "https", - "consul_token": "", - "consul_integration_prefix": "terraform/", - "timezone": "Asia/Singapore", - "prometheus_version": "2.22.0", - "prometheus_db_dir": "/mnt/data", - "prometheus_storage_retention": "90d", - "prometheus_client_service": "prometheus-client", - "prometheus_consul_job_name": "consul", - "prometheus_port": "9090" - }, - "builders": [ - { - "name": "ubuntu-1604-prometheus-ami", - "ami_name": "{{ user `ami_base_name` }}-{{isotime | clean_resource_name}}", - "ami_description": "An Ubuntu 16.04 AMI that has Prometheus installed.", - "instance_type": "t3.micro", - "region": "{{user `aws_region`}}", - "type": "amazon-ebs", - "subnet_id": "{{user `subnet_id`}}", - "associate_public_ip_address": "{{user `associate_public_ip_address`}}", - "ssh_interface": "{{user `ssh_interface`}}", - "temporary_security_group_source_cidrs": "{{user `temporary_security_group_source_cidrs`}}", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "architecture": "x86_64", - "name": "*ubuntu-xenial-16.04-amd64-server-*", - "block-device-mapping.volume-type": "gp2", - "root-device-type": "ebs" - }, - "owners": [ - "099720109477" - ], - "most_recent": true - }, - "ssh_username": "ubuntu", - "run_tags": { - "Name": "{{user `ami_base_name` }}-{{isotime | clean_resource_name}}", - "Base Name": "{{user `ami_base_name` }}", - "Timestamp": "{{isotime \"2006-01-02 03:04:05\"}}", - "Packer": "yes", - "Consul Version": "{{user `consul_version` }}", - "Prometheus Version": "{{user `prometheus_version` }}" - }, - "tags": { - "Name": "{{user `ami_base_name` }}-{{isotime | clean_resource_name}}", - "Base Name": "{{user `ami_base_name` }}", - "Timestamp": "{{isotime \"2006-01-02 03:04:05\"}}", - "Packer": "yes", - "Consul Version": "{{user `consul_version` }}", - "Prometheus Version": "{{user `prometheus_version` }}" - }, - "snapshot_tags": { - "Name": "{{user `ami_base_name` }}-{{isotime | clean_resource_name}}", - "Base Name": "{{user `ami_base_name` }}", - "Timestamp": "{{isotime \"2006-01-02 03:04:05\"}}", - "Packer": "yes", - "Consul Version": "{{user `consul_version` }}", - "Prometheus Version": "{{user `prometheus_version` }}" - } - } - ], - "provisioners": [ - { - "type": "shell", - "inline": [ - "timeout 60s bash -c \"while ! [ -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting on cloud-init...'; sleep 2; done\"" - ] - }, - { - "type": "ansible", - "playbook_file": "{{ template_dir }}/site.yml", - "user": "ubuntu", - "extra_arguments": [ - "-e", - "{ \"additional_ntp_servers\": {{user `additional_ntp_servers`}} }", - "-e", - "consul_module_version={{user `consul_module_version`}} consul_version={{user `consul_version`}} consul_module_repo={{user `consul_module_repo`}}", - "-e", - "{ \"consul_enable_syslog\": {{user `consul_enable_syslog`}} }", - "-e", - "td_agent_config_file={{user `td_agent_config_file`}} td_agent_config_vars_file={{user `td_agent_config_vars_file`}} td_agent_config_app_vars_file={{user `td_agent_config_app_vars_file`}}", - "-e", - "ca_certificate={{user `ca_certificate`}}", - "-e", - "consul_host={{user `consul_host`}} consul_port={{user `consul_port`}} consul_scheme={{user `consul_scheme`}} consul_token={{user `consul_token`}} consul_integration_prefix={{user `consul_integration_prefix`}}", - "-e", - "prometheus_version={{user `prometheus_version`}} prometheus_db_dir={{user `prometheus_db_dir`}} prometheus_storage_retention={{user `prometheus_storage_retention`}} prometheus_client_service={{user `prometheus_client_service`}} prometheus_consul_job_name={{user `prometheus_consul_job_name`}} prometheus_port={{user `prometheus_port`}}", - "-e", - "timezone={{user `timezone`}}", - "-e", - "ansible_python_interpreter=\"$(command -v python3)\"" - ] - } - ] -} diff --git a/modules/prometheus/packer/ami/site.yml b/modules/prometheus/packer/ami/site.yml deleted file mode 100644 index bc7ac911..00000000 --- a/modules/prometheus/packer/ami/site.yml +++ /dev/null @@ -1,143 +0,0 @@ ---- -- name: Provision Prometheus AMI - hosts: all - vars: - additional_ntp_servers: ["169.254.169.123"] - consul_module_repo: "https://github.com/hashicorp/terraform-aws-consul.git" - consul_module_version: "v0.3.5" - consul_version: "1.4.0" - consul_enable_syslog: true - td_agent_config_file: "" - td_agent_config_vars_file: "" - td_agent_config_app_vars_file: "" - td_agent_config_dest_file: "/etc/td-agent/td-agent.conf" - ca_certificate: "" - consul_host: "" - consul_port: 443 - consul_scheme: https - consul_token: "" - consul_integration_prefix: "terraform/" - timezone: "Asia/Singapore" - prometheus_version: "2.4.3" - prometheus_db_dir: "/mnt/data" - prometheus_storage_retention: "90d" - prometheus_client_service: "prometheus-client" - prometheus_consul_job_name: "consul" - prometheus_port: 9090 - tasks: - - name: Upgrade all packages to the latest version - apt: - upgrade: yes - update_cache: yes - become: yes - - name: Install CA Certificate - include_tasks: "{{ playbook_dir }}/../../../../tasks/include_role_checked.yml" - vars: - role: "{{ playbook_dir }}/../../../../roles/ansible-ca-store" - certificate: "{{ ca_certificate }}" - certificate_rename: "ca.crt" - become: yes - - name: Install Vault PKI CA Certificate - include_role: - name: "{{ playbook_dir }}/../../../../roles/vault-pki" - - name: Install chrony - include_role: - name: "{{ playbook_dir }}/../../../../roles/chrony" - - name: Install td-agent - include_role: - name: "{{ playbook_dir }}/../../../../roles/td-agent" - vars: - config_file: "{{ td_agent_config_file }}" - config_vars_file: "{{ td_agent_config_vars_file }}" - config_app_vars_file: "{{ td_agent_config_app_vars_file }}" - config_dest_file: "{{ td_agent_config_dest_file }}" - - name: Install Telegraf - include_role: - name: "{{ playbook_dir }}/../../../../roles/telegraf" - - name: Install Consul - include_role: - name: "{{ playbook_dir }}/../../../../roles/consul" - - name: Install Consul-Template - include_role: - name: "{{ playbook_dir }}/../../../../roles/install-consul-template" - - name: Install Vault SSH Configuration Script - include_role: - name: "{{ playbook_dir }}/../../../../roles/install-ssh-script" - - name: Set default timezone - include_role: - name: "{{ playbook_dir }}/../../../../roles/timezone" - - - name: Install Prometheus - include_tasks: "{{ playbook_dir }}/../../../../tasks/include_role_checked.yml" - vars: - role: "{{ playbook_dir }}/../../../../roles/prometheus" - prometheus_web_listen_address: "0.0.0.0:{{ prometheus_port }}" - prometheus_scrape_configs: - - job_name: "{{ prometheus_consul_job_name }}" - consul_sd_configs: - - server: "localhost:8500" - services: - - "{{ prometheus_client_service }}" - allow_stale: false - relabel_configs: - # From https://groups.google.com/forum/#!topic/prometheus-users/Jn6RdehOX0Q - - source_labels: ["__meta_consul_tags"] - action: replace - regex: .*,prometheus_path=([^,]+),.* - replacement: '${1}' - target_label: __metrics_path__ - - source_labels: ["__meta_consul_tags"] - regex: .*,prometheus_disable=true,.* - action: drop - # Convert all the `prometheus_tag_xxx` tags to additional tags for the target - # Due to how the regex works, we have to have as many actions as the number of potential - # tags - # See https://www.robustperception.io/extracting-full-labels-from-consul-tags - - source_labels: ["__meta_consul_tags"] - action: replace - regex: ',(?:[^,]+,){0}prometheus_tag_([^=]+)=([^,]+),.*' - replacement: '${2}' - target_label: '${1}' - - source_labels: ["__meta_consul_tags"] - action: replace - regex: ',(?:[^,]+,){1}prometheus_tag_([^=]+)=([^,]+),.*' - replacement: '${2}' - target_label: '${1}' - - source_labels: ["__meta_consul_tags"] - action: replace - regex: ',(?:[^,]+,){2}prometheus_tag_([^=]+)=([^,]+),.*' - replacement: '${2}' - target_label: '${1}' - - source_labels: ["__meta_consul_tags"] - action: replace - regex: ',(?:[^,]+,){3}prometheus_tag_([^=]+)=([^,]+),.*' - replacement: '${2}' - target_label: '${1}' - - source_labels: ["__meta_consul_tags"] - action: replace - regex: ',(?:[^,]+,){4}prometheus_tag_([^=]+)=([^,]+),.*' - replacement: '${2}' - target_label: '${1}' - - - name: Stop Prometheus Service for the rest of the build - systemd: - name: prometheus - state: stopped - enabled: false - become: yes - - name: Make Prometheus Data Mount directory - file: - state: "{{ item }}" - path: "{{ prometheus_db_dir }}" - owner: "prometheus" - group: "prometheus" - become: yes - loop: - - absent - - directory - - name: Install Prometheus Script - copy: - src: "{{ playbook_dir }}/configure.sh" - dest: /opt/prometheus - mode: 0755 - become: yes diff --git a/modules/prometheus/packer/ami/td-agent-vars.yml b/modules/prometheus/packer/ami/td-agent-vars.yml deleted file mode 100644 index f110c15a..00000000 --- a/modules/prometheus/packer/ami/td-agent-vars.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -consul: - tag: consul - identifier: consul - position_file: /etc/td-agent/positions/consul.pos -consul_template: - tag: consul-template - identifier: consul-template - position_file: /etc/td-agent/positions/consul-template.pos - -additionals: - - tag: cron - identifier: cron - position_file: /etc/td-agent/positions/cron.pos - - tag: td-agent - identifier: td-agent - position_file: /etc/td-agent/positions/td-agent.pos - - tag: telegraf - identifier: telegraf - position_file: /etc/td-agent/positions/telegraf.pos - - tag: sshd - identifier: sshd - position_file: /etc/td-agent/positions/sshd.pos - - tag: sudo - identifier: sudo - position_file: /etc/td-agent/positions/sudo.pos - - tag: prometheus - prefix: services - identifier: prometheus - position_file: /etc/td-agent/positions/prometheus.pos - -user_data_path: /var/log/user-data.log diff --git a/modules/prometheus/packer/data/packer.json b/modules/prometheus/packer/data/packer.json deleted file mode 100644 index eded4e79..00000000 --- a/modules/prometheus/packer/data/packer.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "description": "Create and format an EBS volume for Prometheus data", - "min_packer_version": "1.3.4", - "variables": { - "volume_name": "prometheus-server-data", - "aws_region": "ap-southeast-1", - "subnet_id": "", - "temporary_security_group_source_cidrs": "0.0.0.0/0", - "associate_public_ip_address": "true", - "ssh_interface": "", - "data_volume_size": "400" - }, - "builders": [ - { - "name": "prometheus-data", - "instance_type": "t3.micro", - "region": "{{user `aws_region`}}", - "type": "amazon-ebsvolume", - "subnet_id": "{{user `subnet_id`}}", - "associate_public_ip_address": "{{user `associate_public_ip_address`}}", - "ssh_interface": "{{user `ssh_interface`}}", - "temporary_security_group_source_cidrs": "{{user `temporary_security_group_source_cidrs`}}", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "architecture": "x86_64", - "name": "*ubuntu-xenial-16.04-amd64-server-*", - "block-device-mapping.volume-type": "gp2", - "root-device-type": "ebs" - }, - "owners": [ - "099720109477" - ], - "most_recent": true - }, - "ssh_username": "ubuntu", - "ebs_volumes": [ - { - "volume_type": "gp2", - "device_name": "/dev/sdf", - "delete_on_termination": false, - "volume_size": "{{user `data_volume_size`}}", - "tags": { - "Name": "{{user `volume_name`}}", - "Timestamp": "{{isotime \"2006-01-02 03:04:05\"}}" - } - } - ], - "run_tags": { - "Name": "{{user `volume_name` }}", - "Timestamp": "{{isotime \"2006-01-02 03:04:05\"}}" - } - } - ], - "provisioners": [ - { - "type": "shell", - "inline": [ - "sudo mkfs -t ext4 /dev/nvme1n1" - ] - } - ] -} diff --git a/modules/prometheus/td_agent.tf b/modules/prometheus/td_agent.tf deleted file mode 100644 index 7485fed9..00000000 --- a/modules/prometheus/td_agent.tf +++ /dev/null @@ -1,9 +0,0 @@ -resource "consul_keys" "td_agent" { - count = var.td_agent_enabled ? 1 : 0 - - key { - path = "${var.consul_key_prefix}td-agent/${var.server_type}/enabled" - value = "yes" - delete = true - } -} diff --git a/modules/prometheus/traefik.tf b/modules/prometheus/traefik.tf deleted file mode 100644 index 870a0a42..00000000 --- a/modules/prometheus/traefik.tf +++ /dev/null @@ -1,30 +0,0 @@ -# Traefik Integration -resource "consul_keys" "traefik_enabled" { - count = var.traefik_enabled ? 1 : 0 - - key { - path = "${local.consul_prefix}traefik/enabled" - value = "yes" - delete = true - } -} - -resource "consul_keys" "traefik_fqdns" { - count = var.traefik_enabled ? 1 : 0 - - key { - path = "${local.consul_prefix}traefik/fqdns" - value = join(",", var.traefik_fqdns) - delete = true - } -} - -resource "consul_keys" "traefik_entrypoints" { - count = var.traefik_enabled ? 1 : 0 - - key { - path = "${local.consul_prefix}traefik/entrypoints" - value = join(",", var.traefik_entrypoints) - delete = true - } -} diff --git a/modules/prometheus/variables.tf b/modules/prometheus/variables.tf deleted file mode 100644 index baca0bd3..00000000 --- a/modules/prometheus/variables.tf +++ /dev/null @@ -1,229 +0,0 @@ -variable "ami_id" { - description = "AMI ID for Prometheus Server" -} - -variable "ssh_key_name" { - description = "Name of SSH key to assign to the instance" -} - -variable "subnet_id" { - description = "Subnet ID to deploy the instance to" -} - -variable "consul_security_group_id" { - description = "Security Group ID for Consul servers" -} - -variable "data_volume_id" { - description = "EBS Volume ID for Prometheus Data Storage" -} - -variable "name" { - description = "Base name for resources" - default = "prometheus" -} - -variable "associate_public_ip_address" { - description = "Associate a public IP address for instance" - default = false -} - -variable "instance_type" { - description = "Type of instance to deploy" - default = "t2.micro" -} - -variable "prometheus_service" { - description = "Name of Prometheus server service to register in Consul." - default = "prometheus" -} - -variable "prometheus_client_service" { - description = "Name of the Prometheus Client services to scrape" - default = "prometheus-client" -} - -variable "prometheus_db_dir" { - description = "Path where the data for Prometheus will be stored. This will be where the EBS volume where data is persisted will be mounted." - default = "/mnt/data" -} - -variable "prometheus_port" { - description = "Port at which the server will be listening to." - default = "9090" -} - -variable "data_device_name" { - description = "Path of the EBS device that is mounted" - default = "/dev/nvme1n1" -} - -variable "allowed_ssh_cidr_blocks" { - description = "List of allowed CIDR blocks to allow SSH access" - type = list(string) - default = [] -} - -variable "additional_cidr_blocks" { - description = "Additional CIDR blocks other than the VPC CIDR block thatn can access the Prometheus server" - type = list(string) - default = [] -} - -variable "tags" { - description = "Tags to apply to resources" - - default = { - Terraform = "true" - } -} - -variable "root_volume_size" { - description = "Size of the Prometheus server root volume in GB" - default = 50 -} - -variable "consul_cluster_tag_key" { - description = "Key that Consul Server Instances are tagged with for discovery" - default = "consul-servers" -} - -variable "consul_cluster_tag_value" { - description = "Value that Consul Server Instances are tagged with for discovery" - default = "consul" -} - -variable "data_volume_mount" { - description = "Data volume mount device name" - default = "/dev/sdf" -} - -# -------------------------------------------------------------------------------------------------- -# Traefik Integration -# -------------------------------------------------------------------------------------------------- - -variable "traefik_enabled" { - description = "Enable Traefik Integration" - default = false -} - -variable "traefik_entrypoints" { - description = "List of entrypoints for Traefik" - - # Default "internal" entrypoint - default = ["internal"] -} - -variable "traefik_fqdns" { - description = "List of FQDNs for Traefik to listen to. You have to create the DNS records separately." - type = list(string) - default = [] -} - -# -------------------------------------------------------------------------------------------------- -# AWS Auth Integration -# -------------------------------------------------------------------------------------------------- -variable "aws_auth_enabled" { - description = "Enable AWS Authentication" - default = false -} - -variable "aws_auth_path" { - description = "Path to the Vault AWS Authentication backend" - default = "aws" -} - -variable "aws_auth_vault_role" { - description = "Name of the role in the AWS Authentication backend to create" - default = "prometheus" -} - -variable "aws_auth_policies" { - description = "List of Vault policies to assign to the tokens issued by the AWS authentication backend" - type = list(string) - default = [] -} - -variable "aws_auth_period_minutes" { - description = "Period, in minutes, that the Vault token issued will live for" - default = "60" -} - -# -------------------------------------------------------------------------------------------------- -# Vault SSH Integration -# -------------------------------------------------------------------------------------------------- - -variable "vault_ssh_enabled" { - description = "Enable Vault SSH integration" - default = false -} - -variable "vault_ssh_path" { - description = "Path to mount the SSH secrets engine" - default = "ssh_prometheus" -} - -variable "vault_ssh_role_name" { - description = "Role name for the Vault SSH secrets engine" - default = "default" -} - -variable "vault_ssh_user" { - description = "Username to allow SSH access" - default = "ubuntu" -} - -variable "vault_ssh_ttl" { - description = "TTL for the Vault SSH certificate in seconds" - default = 300 -} - -variable "vault_ssh_max_ttl" { - description = "Max TTL for certificate renewal" - default = 86400 -} - -# -------------------------------------------------------------------------------------------------- -# td-agent Integration -# -------------------------------------------------------------------------------------------------- - -variable "td_agent_enabled" { - description = "Enable td-agent integration. You will still need to provide the appropriate configuration file for td-agent during the AMI building process." - default = false -} - -# -------------------------------------------------------------------------------------------------- -# Curator Integration -# -------------------------------------------------------------------------------------------------- -variable "curator_enable" { - description = "Enable Curator integration for Prometheus" - default = false -} - -variable "curator_age" { - description = "Age in days to retain indices" - default = "90" -} - -variable "curator_prefix" { - description = "Elasticsearch prefix for Curator logs" - default = "services.prometheus" -} - -# -------------------------------------------------------------------------------------------------- -# CORE INTEGRATION SETTINGS -# -------------------------------------------------------------------------------------------------- -variable "consul_key_prefix" { - description = <