├── .ansible-lint ├── .circleci └── config.yml ├── .github ├── ISSUE_TEMPLATE │ ├── bug.md │ ├── feature.md │ └── support.md ├── labeler.yml ├── labels.yml ├── lock.yml ├── settings.yml ├── stale.yml └── workflows │ ├── labeler.yml │ └── labels.yml ├── .gitignore ├── .mergify.yml ├── .yamllint ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── TROUBLESHOOTING.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── molecule └── default │ ├── molecule.yml │ ├── playbook.yml │ ├── prepare.yml │ └── tests │ └── test_default.py ├── tasks ├── configure.yml ├── install.yml ├── main.yml └── preflight.yml ├── templates └── process_exporter.service.j2 ├── test-requirements.txt └── vars ├── debian.yml ├── main.yml ├── redhat-7.yml └── redhat.yml /.ansible-lint: -------------------------------------------------------------------------------- 1 | --- 2 | skip_list: 3 | - '204' 4 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2.1 3 | 4 | executors: 5 | python: 6 | docker: 7 | - image: cimg/python:3.9 8 | 9 | jobs: 10 | lint: 11 | executor: python 12 | steps: 13 | - checkout 14 | - run: pip install ansible-lint yamllint flake8 15 | - run: ansible-lint 16 | - run: yamllint . 17 | - run: flake8 18 | 19 | test: 20 | executor: python 21 | parameters: 22 | ansible: 23 | type: string 24 | environment: 25 | ANSIBLE: "<< parameters.ansible >>" 26 | steps: 27 | - checkout 28 | - setup_remote_docker 29 | - run: ln -s ~/project ~/${CIRCLE_PROJECT_REPONAME} 30 | - run: pip install -r test-requirements.txt 31 | - run: molecule test -s default --destroy always 32 | - run: | 33 | if [[ -d 'molecule/alternative' ]]; then 34 | molecule test -s alternative --destroy never 35 | else 36 | echo 'No alternative test' 37 | fi 38 | - run: | 39 | if [[ -z "${CIRCLE_PULL_REQUEST}" ]]; then 40 | molecule test -s latest --destroy never 41 | else 42 | echo 'Not running latest on PR' 43 | fi 44 | release: 45 | executor: python 46 | environment: 47 | GIT_MAIL: cloudalchemybot@gmail.com 48 | GIT_USER: cloudalchemybot 49 | GIT_COMMIT_DESC: git log --format=%B -n 1 ${CIRCLE_SHA1} 50 | steps: 51 | - checkout 52 | - setup_remote_docker 53 | - run: pip install git-semver 54 | - run: git config --global user.email "${GIT_MAIL}" 55 | - run: git config --global user.name "${GIT_USER}" 56 | - run: | 57 | GIT_TAG=none 58 | echo "Last commit message: ${GIT_COMMIT_DESC}" 59 | case "${GIT_COMMIT_DESC}" in 60 | *"[patch]"*|*"[fix]"*|*"[bugfix]"* ) GIT_TAG=$(git semver --next-patch) ;; 61 | *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;; 62 | *"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;; 63 | *) echo "Keyword not detected. Doing nothing" && circleci-agent step halt ;; 64 | esac 65 | echo "GIT_TAG=${GIT_TAG}" >> $BASH_ENV 66 | - run: | 67 | docker run -it --rm \ 68 | -v "${CIRCLE_WORKING_DIRECTORY}:/role" \ 69 | -w "/role" \ 70 | ferrarimarco/github-changelog-generator:1.15.2 \ 71 | --user "${CIRCLE_PROJECT_USERNAME}" \ 72 | --project "${CIRCLE_PROJECT_REPONAME}" \ 73 | --token "${GH_TOKEN}" \ 74 | --release-url "https://galaxy.ansible.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME#ansible-}" \ 75 | --unreleased-label "**Next release**" --no-compare-link \ 76 | --future-release "${GIT_TAG}" 77 | - run: git add CHANGELOG.md 78 | - run: git commit -m "[ci skip] Automatic changelog update" 79 | - run: git push "https://${GH_TOKEN}:@${GIT_URL}" || circleci-agent step halt 80 | - run: | 81 | ghr \ 82 | -t ${GH_TOKEN} \ 83 | -u ${CIRCLE_PROJECT_USERNAME} \ 84 | -r ${CIRCLE_PROJECT_REPONAME} \ 85 | -n ${GIT_TAG} \ 86 | -b "$(sed -n -e '/## \[0.22.0\]/,/## \[/ p' CHANGELOG.md | sed -e '$ d')" \ 87 | ${GIT_TAG} 88 | galaxy: 89 | executor: python 90 | steps: 91 | - checkout 92 | - run: pip install ansible 93 | - run: ansible-galaxy role import --token "${GALAXY_TOKEN}" "${CIRCLE_PROJECT_USERNAME}" "${CIRCLE_PROJECT_REPONAME}" 94 | 95 | workflows: 96 | version: 2 97 | molecule: 98 | jobs: 99 | - lint: 100 | filters: 101 | tags: 102 | only: /.*/ 103 | - test: 104 | matrix: 105 | parameters: 106 | ansible: 107 | - "2.9" 108 | - "2.10" 109 | filters: 110 | tags: 111 | only: /.*/ 112 | - release: 113 | context: release 114 | requires: 115 | - lint 116 | - test 117 | filters: 118 | branches: 119 | only: master 120 | tags: 121 | ignore: /.*/ 122 | - galaxy: 123 | context: galaxy 124 | requires: 125 | - lint 126 | - test 127 | - release 128 | filters: 129 | branches: 130 | only: master 131 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug 3 | about: Report a bug related to ansible role 4 | labels: bug 5 | --- 6 | 7 | **What happened?** 8 | 9 | **Did you expect to see some different?** 10 | 11 | **How to reproduce it (as minimally and precisely as possible)**: 12 | 13 | **Environment** 14 | 15 | * Role version: 16 | 17 | `Insert release version/galaxy tag or Git SHA here` 18 | 19 | * Ansible version information: 20 | 21 | `ansible --version` 22 | 23 | 24 | * Variables: 25 | 26 | ``` 27 | insert role variables relevant to the issue 28 | ``` 29 | 30 | * Ansible playbook execution Logs: 31 | 32 | ``` 33 | insert Ansible logs relevant to the issue here 34 | ``` 35 | 36 | **Anything else we need to know?**: 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature 3 | about: If you want to propose a new feature or enhancement 4 | labels: enhancement 5 | --- 6 | 7 | **What is missing?** 8 | 9 | **Why do we need it?** 10 | 11 | **Environment** 12 | 13 | * Role version: 14 | 15 | `Insert release version/galaxy tag or Git SHA here` 16 | 17 | * Ansible version information: 18 | 19 | `ansible --version` 20 | 21 | 22 | **Anything else we need to know?**: 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support 3 | about: If you have questions about this ansible role 4 | labels: question 5 | --- 6 | 7 | **What did you do?** 8 | 9 | **Did you expect to see some different?** 10 | 11 | **Environment** 12 | 13 | * Role version: 14 | 15 | `Insert release version/galaxy tag or Git SHA here` 16 | 17 | * Ansible version information: 18 | 19 | `ansible --version` 20 | 21 | 22 | * Variables: 23 | 24 | ``` 25 | insert role variables relevant to the issue 26 | ``` 27 | 28 | * Ansible playbook execution Logs: 29 | 30 | ``` 31 | insert Ansible logs relevant to the issue here 32 | ``` 33 | 34 | **Anything else we need to know?**: 35 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # configuration spec at https://github.com/actions/labeler/blob/master/README.md 3 | area/docs: 4 | - meta/* 5 | - CHANGELOG.md 6 | - CONTRIBUTING.md 7 | - LICENSE 8 | - README.md 9 | area/tests: 10 | - molecule/* 11 | - molecule/**/* 12 | - .ansible-lint 13 | - test-requirements.txt 14 | - tox.ini 15 | area/automation: 16 | - .travis/* 17 | - .github/* 18 | - .github/**/* 19 | - .travis.yml 20 | - .mergify.yml 21 | area/vars: 22 | - defaults/* 23 | - vars/* 24 | - vars/**/* 25 | area/tasks: 26 | - handlers/* 27 | - tasks/* 28 | - tasks/**/* 29 | area/jinja: 30 | - templates/* 31 | - templates/**/* 32 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Default GitHub labels 3 | - color: d73a4a 4 | name: bug 5 | description: Something isn't working 6 | - color: cfd3d7 7 | name: duplicate 8 | description: This issue or pull request already exists 9 | - color: a2eeef 10 | name: enhancement 11 | description: New feature or request 12 | - color: 7057ff 13 | name: good first issue 14 | description: Good for newcomers 15 | - color: 008672 16 | name: help wanted 17 | description: Extra attention is needed 18 | - color: e4e669 19 | name: invalid 20 | description: This doesn't seem right 21 | - color: d876e3 22 | name: question 23 | description: Further information is requested 24 | - color: ffffff 25 | name: wontfix 26 | description: This will not be worked on 27 | 28 | # Labels specific to cloudalchemy 29 | - color: 0366d6 30 | name: area/docs 31 | description: Improvements or additions to documentation 32 | - color: 0366d6 33 | name: area/tests 34 | description: Everything related to molecule tests and linters 35 | - color: 0366d6 36 | name: area/automation 37 | description: Bots, bots everywhere 38 | - color: 0366d6 39 | name: area/vars 40 | description: Ansible variables used in role 41 | - color: 0366d6 42 | name: area/tasks 43 | description: Logic behind ansible role 44 | - color: 0366d6 45 | name: area/jinja 46 | description: Templates 47 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | --- 2 | _extends: auto-maintenance 3 | -------------------------------------------------------------------------------- /.github/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | _extends: auto-maintenance 3 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | --- 2 | _extends: auto-maintenance 3 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pull request labeler 3 | on: 4 | schedule: 5 | - cron: '*/15 * * * *' 6 | jobs: 7 | labeler: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: paulfantom/periodic-labeler@master 11 | env: 12 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 13 | GITHUB_REPOSITORY: ${{ github.repository }} 14 | -------------------------------------------------------------------------------- /.github/workflows/labels.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Sync labels in the declarative way 3 | on: 4 | push: 5 | branches: 6 | - master 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@1.0.0 12 | - uses: micnncim/action-label-syncer@v0.3.1 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | GITHUB_REPOSITORY: ${{ github.repository }} 16 | with: 17 | manifest: .github/labels.yml 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.retry 2 | *.log 3 | .molecule 4 | .cache 5 | __pycache__/ 6 | .pytest_cache 7 | .tox 8 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | pull_request_rules: 3 | - name: automatic merge and new release from cloudalchemybot 4 | conditions: 5 | - "status-success=Travis CI - Pull Request" 6 | - status-success=WIP 7 | - head~=autoupdate|skeleton 8 | - author=cloudalchemybot 9 | actions: 10 | merge: 11 | method: squash 12 | strict: true 13 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | ignore: | 4 | .github/ 5 | meta/ 6 | 7 | rules: 8 | braces: 9 | max-spaces-inside: 1 10 | level: error 11 | brackets: 12 | max-spaces-inside: 1 13 | level: error 14 | line-length: disable 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [0.2.0](https://galaxy.ansible.com/cloudalchemy/process_exporter) (2020-10-19) 4 | **Merged pull requests:** 5 | 6 | - fix user and group creation [\#29](https://github.com/cloudalchemy/ansible-process_exporter/pull/29) ([tombokombo](https://github.com/tombokombo)) 7 | - New ncabatoff/process-exporter upstream release! [\#28](https://github.com/cloudalchemy/ansible-process_exporter/pull/28) ([cloudalchemybot](https://github.com/cloudalchemybot)) 8 | - \[REPO SYNC\] add troubleshooting doc skeleton [\#27](https://github.com/cloudalchemy/ansible-process_exporter/pull/27) ([cloudalchemybot](https://github.com/cloudalchemybot)) 9 | - \[REPO SYNC\] Add passlib as a test requirement [\#26](https://github.com/cloudalchemy/ansible-process_exporter/pull/26) ([cloudalchemybot](https://github.com/cloudalchemybot)) 10 | - \[REPO SYNC\] lock molecule to v2 [\#25](https://github.com/cloudalchemy/ansible-process_exporter/pull/25) ([cloudalchemybot](https://github.com/cloudalchemybot)) 11 | - \[REPO SYNC\] Merge pull request \#4 from cloudalchemy/travis\_fix [\#24](https://github.com/cloudalchemy/ansible-process_exporter/pull/24) ([cloudalchemybot](https://github.com/cloudalchemybot)) 12 | - \[REPO SYNC\] use latest available python [\#23](https://github.com/cloudalchemy/ansible-process_exporter/pull/23) ([cloudalchemybot](https://github.com/cloudalchemybot)) 13 | 14 | ## [0.1.1](https://galaxy.ansible.com/cloudalchemy/process_exporter) (2020-01-01) 15 | **Merged pull requests:** 16 | 17 | - New ncabatoff/process-exporter upstream release! [\#21](https://github.com/cloudalchemy/ansible-process_exporter/pull/21) ([cloudalchemybot](https://github.com/cloudalchemybot)) 18 | - \[REPO SYNC\] remove IRC link [\#20](https://github.com/cloudalchemy/ansible-process_exporter/pull/20) ([cloudalchemybot](https://github.com/cloudalchemybot)) 19 | - \[REPO SYNC\] .github/workflows: less frequent label sync [\#19](https://github.com/cloudalchemy/ansible-process_exporter/pull/19) ([cloudalchemybot](https://github.com/cloudalchemybot)) 20 | - \[REPO SYNC\] add declarative label sync; add autolabelling PRs [\#18](https://github.com/cloudalchemy/ansible-process_exporter/pull/18) ([cloudalchemybot](https://github.com/cloudalchemybot)) 21 | 22 | ## [0.1.0](https://galaxy.ansible.com/cloudalchemy/process_exporter) (2019-11-14) 23 | **Merged pull requests:** 24 | 25 | - \[REPO SYNC\] molecule: use CI images from quay.io instead of dockerhub [\#16](https://github.com/cloudalchemy/ansible-process_exporter/pull/16) ([cloudalchemybot](https://github.com/cloudalchemybot)) 26 | 27 | ## [0.0.0](https://galaxy.ansible.com/cloudalchemy/process_exporter) (2019-11-05) 28 | **Closed issues:** 29 | 30 | - update of process\_exporter\_names needs reload/restart [\#12](https://github.com/cloudalchemy/ansible-process_exporter/issues/12) 31 | - default process\_exporter\_names [\#10](https://github.com/cloudalchemy/ansible-process_exporter/issues/10) 32 | 33 | **Merged pull requests:** 34 | 35 | - \[REPO SYNC\] Update releaser.sh [\#15](https://github.com/cloudalchemy/ansible-process_exporter/pull/15) ([cloudalchemybot](https://github.com/cloudalchemybot)) 36 | - \[REPO SYNC\] add support for CentOS8 [\#14](https://github.com/cloudalchemy/ansible-process_exporter/pull/14) ([cloudalchemybot](https://github.com/cloudalchemybot)) 37 | - process\_exporter\_names restart [\#13](https://github.com/cloudalchemy/ansible-process_exporter/pull/13) ([gajowi](https://github.com/gajowi)) 38 | - Default names [\#11](https://github.com/cloudalchemy/ansible-process_exporter/pull/11) ([gajowi](https://github.com/gajowi)) 39 | - make config file readable [\#9](https://github.com/cloudalchemy/ansible-process_exporter/pull/9) ([gajowi](https://github.com/gajowi)) 40 | - fix config file extension [\#8](https://github.com/cloudalchemy/ansible-process_exporter/pull/8) ([gajowi](https://github.com/gajowi)) 41 | - explain naming [\#7](https://github.com/cloudalchemy/ansible-process_exporter/pull/7) ([gajowi](https://github.com/gajowi)) 42 | - Synchronize files from cloudalchemy/skeleton [\#6](https://github.com/cloudalchemy/ansible-process_exporter/pull/6) ([cloudalchemybot](https://github.com/cloudalchemybot)) 43 | - Synchronize files from cloudalchemy/skeleton [\#3](https://github.com/cloudalchemy/ansible-process_exporter/pull/3) ([cloudalchemybot](https://github.com/cloudalchemybot)) 44 | - New ncabatoff/process-exporter upstream release! [\#2](https://github.com/cloudalchemy/ansible-process_exporter/pull/2) ([cloudalchemybot](https://github.com/cloudalchemybot)) 45 | - added restartsec and startlimitinterval configurations [\#1](https://github.com/cloudalchemy/ansible-process_exporter/pull/1) ([oguzhaninan](https://github.com/oguzhaninan)) 46 | 47 | 48 | 49 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributor Guideline 2 | 3 | This document provides an overview of how you can participate in improving this project or extending it. We are 4 | grateful for all your help: bug reports and fixes, code contributions, documentation or ideas. Feel free to join, we 5 | appreciate your support!! 6 | 7 | ## Communication 8 | 9 | ### GitHub repositories 10 | 11 | Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report 12 | bugs, ask questions, and request new features . 13 | 14 | ## git and GitHub 15 | 16 | In order to contribute code please: 17 | 18 | 1. Fork the project on GitHub 19 | 2. Clone the project 20 | 3. Add changes (and tests) 21 | 4. Commit and push 22 | 5. Create a merge-request 23 | 24 | To have your code merged, see the expectations listed below. 25 | 26 | You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo). 27 | 28 | Please follow common commit best-practices. Be explicit, have a short summary, a well-written description and 29 | references. This is especially important for the merge-request. 30 | 31 | Some great guidelines can be found [here](https://wiki.openstack.org/wiki/GitCommitMessages) and 32 | [here](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message). 33 | 34 | ## Releases 35 | 36 | We try to stick to semantic versioning and our releases are automated. Release is created by assigning a keyword (in a 37 | way similar to travis [`[ci skip]`](https://docs.travis-ci.com/user/customizing-the-build#Skipping-a-build)) to a 38 | commit with merge request. Available keywords are (square brackets are important!): 39 | 40 | * `[patch]`, `[fix]` - for PATCH version release 41 | * `[minor]`, `[feature]`, `[feat]` - for MINOR version release 42 | * `[major]`, `[breaking change]` - for MAJOR version release 43 | 44 | ## Changelog 45 | 46 | Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs 47 | and labels. 48 | 49 | ## Expectations 50 | 51 | ### Keep it simple 52 | 53 | We try to provide production ready ansible roles which should be as much zero-conf as possible but this doesn't mean to 54 | overcomplicate things. Just follow [KISS](https://en.wikipedia.org/wiki/KISS_principle). 55 | 56 | ### Be explicit 57 | 58 | * Please avoid using nonsensical property and variable names. 59 | * Use self-describing attribute names for user configuration. 60 | * In case of failures, communicate what happened and why a failure occurs to the user. Make it easy to track the code 61 | or action that produced the error. Try to catch and handle errors if possible to provide improved failure messages. 62 | 63 | 64 | ### Add tests 65 | 66 | We are striving to use at least two test scenarios located in [/molecule](molecule) directory. First one 67 | ([default](molecule/default)) is testing default configuration without any additional variables, second one 68 | ([alternative](molecule/alternative)) is testing what happens when many variables from 69 | [/defaults/main.yml](defaults/main.yml) are changed. When adding new functionalities please add tests to proper 70 | scenarios. Tests are written in testinfra framework and are located in `/tests` subdirectory of scenario directory 71 | (for example default tests are in [/molecule/default/tests](molecule/default/tests)). 72 | More information about: 73 | - [testinfra](http://testinfra.readthedocs.io/en/latest/index.html) 74 | - [molecule](https://molecule.readthedocs.io/en/latest/index.html) 75 | 76 | ### Follow best practices 77 | 78 | Please follow [ansible best practices](http://docs.ansible.com/ansible/latest/playbooks_best_practices.html) and 79 | especially provide meaningful names to tasks and even comments where needed. 80 | 81 | Our test framework automatically lints code with [`yamllint`](https://yamllint.readthedocs.io) and 82 | [`ansible-lint`](https://github.com/willthames/ansible-lint) programs so be sure to follow their rules. 83 | 84 | Remember: Code is generally read much more often than written. 85 | 86 | ### Use Markdown 87 | 88 | Wherever possible, please refrain from any other formats and stick to simple markdown. 89 | 90 | ## Requirements regarding roles design 91 | 92 | We are trying to create the best and most secure installation method for non-containerized prometheus stack components. 93 | To accomplish this all roles need to support: 94 | 95 | - current and at least one previous ansible version (wherever possible we try to support 2 previous ansible versions) 96 | - systemd as the only available process manager 97 | - at least latest debian and CentOS distributions 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-2019 Pawel Krupa and Pawel Krupa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | **This role has been deprecated in favor of a the [prometheus-community/ansible](https://github.com/prometheus-community/ansible) collection.** 4 | 5 | # Ansible Role: process_exporter 6 | 7 | [![Build Status](https://travis-ci.com/cloudalchemy/ansible-process_exporter.svg?branch=master)](https://travis-ci.com/cloudalchemy/ansible-process_exporter) 8 | [![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT) 9 | [![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.process_exporter-blue.svg)](https://galaxy.ansible.com/cloudalchemy/process_exporter/) 10 | [![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-process_exporter.svg)](https://github.com/cloudalchemy/ansible-process_exporter/tags) 11 | 12 | ## Description 13 | 14 | Deploy [process-exporter](https://github.com/ncabatoff/process-exporter) using ansible. 15 | 16 | Note. This repository and role uses the name process_exporter to conform with ansible galaxy constraints. 17 | 18 | ## Requirements 19 | 20 | - Ansible >= 2.7 (It might work on previous versions, but we cannot guarantee it) 21 | 22 | ## Role Variables 23 | 24 | All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below. 25 | 26 | | Name | Default Value | Description | 27 | | -------------- | ------------- | -----------------------------------| 28 | | `process_exporter_version` | 0.7.5 | Process exporter package version. Also accepts latest as parameter | 29 | | `process_exporter_web_listen_address` | "0.0.0.0:9256" | Address on which process_exporter will listen | 30 | | `process_exporter_config_dir` | "/etc/process_exporter" | Path to directory with process_exporter configuration | 31 | | `process_exporter_names` | [see: defaults/main.yml](defaults/main.yml#L8) | Processes which should be monitored. Syntax is the same as in https://github.com/ncabatoff/process-exporter#using-a-config-file Default is consistent with deb/rpm packages.| 32 | 33 | `process_exporter_names` handling has been set up in an unusual way to handle recommended process-exporter 'Template variables' (such as {{.Comm}}). Follow the example in [defaults/main.yml](defaults/main.yml) if you want to define custom filtering/grouping of processes that use Template variables and make sure to keep the {% raw %} block delimiters. 34 | 35 | ## Example 36 | 37 | ### Playbook 38 | 39 | Use it in a playbook as follows: 40 | ```yaml 41 | - hosts: all 42 | roles: 43 | - cloudalchemy.process_exporter 44 | ``` 45 | 46 | ## Local Testing 47 | 48 | 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. 49 | We are using tox to simplify process of testing on multiple ansible versions. To install tox execute: 50 | ```sh 51 | pip3 install tox 52 | ``` 53 | To run tests on all ansible versions (WARNING: this can take some time) 54 | ```sh 55 | tox 56 | ``` 57 | To run a custom molecule command on custom environment with only default test scenario: 58 | ```sh 59 | tox -e py35-ansible28 -- molecule test -s default 60 | ``` 61 | For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/). 62 | 63 | If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests. 64 | 65 | ## Travis CI 66 | 67 | 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. 68 | 69 | ## Contributing 70 | 71 | See [contributor guideline](CONTRIBUTING.md). 72 | 73 | ## Troubleshooting 74 | 75 | See [troubleshooting](TROUBLESHOOTING.md). 76 | 77 | ## License 78 | 79 | This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details. 80 | -------------------------------------------------------------------------------- /TROUBLESHOOTING.md: -------------------------------------------------------------------------------- 1 | # Troubleshooting 2 | 3 | 4 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | process_exporter_version: 0.7.5 3 | 4 | process_exporter_web_listen_address: "0.0.0.0:9256" 5 | 6 | process_exporter_config_dir: '/etc/process_exporter' 7 | 8 | # Process names 9 | # "raw" section is needed to avoid attempted interpretation 10 | # of process-exporter Template varables (like {{.Comm}}) 11 | process_exporter_names: | 12 | {% raw %} 13 | - name: "{{.Comm}}" 14 | cmdline: 15 | - '.+' 16 | {% endraw %} 17 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: restart process_exporter 3 | become: true 4 | systemd: 5 | daemon_reload: true 6 | name: process_exporter 7 | state: restarted 8 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Pawel Krupa 4 | description: Deploy process_exporter 5 | role_name: process_exporter 6 | license: MIT 7 | company: none 8 | min_ansible_version: 2.7 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - bionic 13 | - xenial 14 | - name: Debian 15 | versions: 16 | - stretch 17 | - buster 18 | - name: EL 19 | versions: 20 | - 7 21 | - 8 22 | - name: Fedora 23 | versions: 24 | - 30 25 | - 31 26 | galaxy_tags: 27 | - monitoring 28 | 29 | dependencies: [] 30 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | dependency: 3 | name: galaxy 4 | driver: 5 | name: docker 6 | # lint: | 7 | # set -e 8 | # yamllint . 9 | # ansible-lint 10 | # flake8 11 | platforms: 12 | - name: bionic 13 | pre_build_image: true 14 | image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04 15 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 16 | privileged: true 17 | volumes: 18 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 19 | - name: xenial 20 | pre_build_image: true 21 | image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04 22 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 23 | privileged: true 24 | volumes: 25 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 26 | - name: stretch 27 | pre_build_image: true 28 | image: quay.io/paulfantom/molecule-systemd:debian-9 29 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 30 | privileged: true 31 | volumes: 32 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 33 | - name: buster 34 | pre_build_image: true 35 | image: quay.io/paulfantom/molecule-systemd:debian-10 36 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 37 | privileged: true 38 | volumes: 39 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 40 | - name: centos7 41 | pre_build_image: true 42 | image: quay.io/paulfantom/molecule-systemd:centos-7 43 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 44 | privileged: true 45 | volumes: 46 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 47 | - name: centos8 48 | pre_build_image: true 49 | image: quay.io/paulfantom/molecule-systemd:centos-8 50 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 51 | privileged: true 52 | volumes: 53 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 54 | groups: 55 | - python3 56 | - name: fedora 57 | pre_build_image: true 58 | image: quay.io/paulfantom/molecule-systemd:fedora-30 59 | docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}" 60 | privileged: true 61 | volumes: 62 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 63 | groups: 64 | - python3 65 | provisioner: 66 | name: ansible 67 | playbooks: 68 | prepare: prepare.yml 69 | converge: playbook.yml 70 | inventory: 71 | group_vars: 72 | python3: 73 | ansible_python_interpreter: /usr/bin/python3 74 | verifier: 75 | name: testinfra 76 | -------------------------------------------------------------------------------- /molecule/default/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | any_errors_fatal: true 4 | roles: 5 | - ansible-process_exporter 6 | -------------------------------------------------------------------------------- /molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Prepare 3 | hosts: all 4 | gather_facts: false 5 | tasks: [] 6 | -------------------------------------------------------------------------------- /molecule/default/tests/test_default.py: -------------------------------------------------------------------------------- 1 | import os 2 | import testinfra.utils.ansible_runner 3 | 4 | testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( 5 | os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') 6 | 7 | 8 | def test_directories(host): 9 | dirs = [ 10 | "/etc/process_exporter" 11 | ] 12 | for dir in dirs: 13 | d = host.file(dir) 14 | assert d.is_directory 15 | assert d.exists 16 | 17 | 18 | def test_files(host): 19 | files = [ 20 | "/etc/systemd/system/process_exporter.service", 21 | "/usr/local/bin/process_exporter", 22 | ] 23 | for file in files: 24 | f = host.file(file) 25 | assert f.exists 26 | assert f.is_file 27 | 28 | 29 | def test_user(host): 30 | assert host.group("process-exp").exists 31 | assert "process-exp" in host.user("process-exp").groups 32 | assert host.user("process-exp").shell == "/usr/sbin/nologin" 33 | assert host.user("process-exp").home == "/" 34 | 35 | 36 | def test_service(host): 37 | s = host.service("process_exporter") 38 | # assert s.is_enabled 39 | assert s.is_running 40 | 41 | 42 | def test_socket(host): 43 | sockets = [ 44 | "tcp://0.0.0.0:9256" 45 | ] 46 | for socket in sockets: 47 | s = host.socket(socket) 48 | assert s.is_listening 49 | -------------------------------------------------------------------------------- /tasks/configure.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Copy the process_exporter systemd service file 3 | template: 4 | src: process_exporter.service.j2 5 | dest: /etc/systemd/system/process_exporter.service 6 | owner: root 7 | group: root 8 | mode: 0644 9 | notify: restart process_exporter 10 | 11 | - name: Create/Update configuration file 12 | copy: 13 | dest: "{{ process_exporter_config_dir }}/config.yml" 14 | content: | 15 | process_names: 16 | {{ process_exporter_names }} 17 | backup: false 18 | owner: root 19 | mode: 0644 20 | when: 21 | - process_exporter_names != [] 22 | notify: restart process_exporter 23 | 24 | - name: Allow process_exporter port in SELinux on RedHat OS family 25 | seport: 26 | ports: "{{ process_exporter_web_listen_address.split(':')[-1] }}" 27 | proto: tcp 28 | setype: http_port_t 29 | state: present 30 | when: 31 | - ansible_version.full is version_compare('2.4', '>=') 32 | - ansible_selinux.status == "enabled" 33 | -------------------------------------------------------------------------------- /tasks/install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install dependencies 3 | package: 4 | name: "{{ item }}" 5 | state: present 6 | register: _install_dep_packages 7 | until: _install_dep_packages is success 8 | retries: 5 9 | delay: 2 10 | with_items: "{{ process_exporter_dependencies }}" 11 | 12 | - name: Create the process_exporter group 13 | group: 14 | name: "{{ process_exporter_system_group }}" 15 | state: present 16 | system: true 17 | when: 18 | - process_exporter_system_group != "root" 19 | 20 | - name: Create the process_exporter user 21 | user: 22 | name: "{{ process_exporter_system_user }}" 23 | groups: "{{ process_exporter_system_group }}" 24 | append: true 25 | shell: /usr/sbin/nologin 26 | system: true 27 | createhome: false 28 | home: / 29 | when: 30 | - process_exporter_system_user != "root" 31 | 32 | - name: create prometheus data directory 33 | file: 34 | path: "{{ process_exporter_config_dir }}" 35 | state: directory 36 | owner: "{{ process_exporter_system_user }}" 37 | group: "{{ process_exporter_system_group }}" 38 | mode: 0755 39 | 40 | - name: Download process_exporter binary to local folder 41 | become: false 42 | get_url: 43 | url: "https://github.com/ncabatoff/process-exporter/releases/download/v{{ process_exporter_version }}/process-exporter-{{ process_exporter_version }}.linux-{{ go_arch }}.tar.gz" 44 | dest: "/tmp/process-exporter-{{ process_exporter_version }}.linux-{{ go_arch }}.tar.gz" 45 | checksum: "sha256:{{ process_exporter_checksum }}" 46 | register: _download_binary 47 | until: _download_binary is succeeded 48 | retries: 5 49 | delay: 2 50 | delegate_to: localhost 51 | check_mode: false 52 | 53 | - name: Unpack process_exporter binary 54 | become: false 55 | unarchive: 56 | src: "/tmp/process-exporter-{{ process_exporter_version }}.linux-{{ go_arch }}.tar.gz" 57 | dest: "/tmp" 58 | creates: "/tmp/process-exporter-{{ process_exporter_version }}.linux-{{ go_arch }}/process-exporter" 59 | delegate_to: localhost 60 | check_mode: false 61 | 62 | - name: Create /usr/local/bin 63 | file: 64 | path: /usr/local/bin 65 | state: directory 66 | mode: 0755 67 | 68 | - name: Propagate process_exporter binaries 69 | copy: 70 | src: "/tmp/process-exporter-{{ process_exporter_version }}.linux-{{ go_arch }}/process-exporter" 71 | dest: "/usr/local/bin/process_exporter" 72 | mode: 0755 73 | owner: root 74 | group: root 75 | notify: restart process_exporter 76 | when: not ansible_check_mode 77 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Gather variables for each operating system 3 | include_vars: "{{ item }}" 4 | with_first_found: 5 | - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" 6 | - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" 7 | - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" 8 | - "{{ ansible_distribution_file_variety | lower }}.yml" 9 | - "{{ ansible_distribution | lower }}.yml" 10 | - "{{ ansible_os_family | lower }}.yml" 11 | tags: 12 | - process_exporter_install 13 | - process_exporter_configure 14 | - process_exporter_run 15 | 16 | - import_tasks: preflight.yml 17 | tags: 18 | - process_exporter_install 19 | - process_exporter_configure 20 | - process_exporter_run 21 | 22 | - import_tasks: install.yml 23 | become: true 24 | tags: 25 | - process_exporter_install 26 | 27 | - import_tasks: configure.yml 28 | become: true 29 | tags: 30 | - process_exporter_configure 31 | 32 | - name: Ensure process_exporter is enabled on boot 33 | become: true 34 | systemd: 35 | daemon_reload: true 36 | name: process_exporter 37 | enabled: true 38 | tags: 39 | - process_exporter_run 40 | -------------------------------------------------------------------------------- /tasks/preflight.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Fail on unsupported init systems 3 | fail: 4 | msg: "This module only works with systemd" 5 | when: ansible_service_mgr != 'systemd' 6 | 7 | - name: Get systemd version 8 | command: systemctl --version 9 | changed_when: false 10 | check_mode: false 11 | register: __systemd_version 12 | tags: 13 | - skip_ansible_lint 14 | 15 | - name: Naive assertion of proper listen address 16 | assert: 17 | that: 18 | - "':' in process_exporter_web_listen_address" 19 | 20 | - block: 21 | - name: Get latest release 22 | uri: 23 | url: "https://api.github.com/repos/ncabatoff/process-exporter/releases/latest" 24 | method: GET 25 | return_content: true 26 | status_code: 200 27 | body_format: json 28 | validate_certs: false 29 | user: "{{ lookup('env', 'GH_USER') | default(omit) }}" 30 | password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}" 31 | no_log: true 32 | register: _latest_release 33 | until: _latest_release.status == 200 34 | retries: 5 35 | 36 | - name: "Set process_exporter version to {{ _latest_release.json.tag_name[1:] }}" 37 | set_fact: 38 | process_exporter_version: "{{ _latest_release.json.tag_name[1:] }}" 39 | when: process_exporter_version == "latest" 40 | delegate_to: localhost 41 | run_once: true 42 | 43 | - name: Get checksum list from github 44 | set_fact: 45 | _checksums: "{{ lookup('url', 'https://github.com/ncabatoff/process-exporter/releases/download/v' + process_exporter_version + '/checksums.txt', wantlist=True) | list }}" 46 | run_once: true 47 | 48 | - name: "Get checksum for {{ go_arch }} architecture" 49 | set_fact: 50 | process_exporter_checksum: "{{ item.split(' ')[0] }}" 51 | with_items: "{{ _checksums }}" 52 | when: "('linux-' + go_arch + '.tar.gz') in item" 53 | -------------------------------------------------------------------------------- /templates/process_exporter.service.j2: -------------------------------------------------------------------------------- 1 | {{ ansible_managed | comment }} 2 | 3 | [Unit] 4 | Description=Process Exporter for Prometheus 5 | After=network-online.target 6 | StartLimitInterval=0 7 | 8 | [Service] 9 | Type=simple 10 | User={{ process_exporter_system_user }} 11 | Group={{ process_exporter_system_group }} 12 | ExecStart=/usr/local/bin/process_exporter \ 13 | {% if process_exporter_names != [] -%} 14 | --config.path {{ process_exporter_config_dir }}/config.yml \ 15 | {% endif -%} 16 | --web.listen-address={{ process_exporter_web_listen_address }} 17 | 18 | SyslogIdentifier=process_exporter 19 | Restart=always 20 | RestartSec=1 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | molecule>=3.0.0 2 | molecule-docker 3 | docker 4 | ansible-lint>=3.4.0 5 | testinfra>=1.7.0 6 | jmespath 7 | selinux 8 | passlib 9 | -------------------------------------------------------------------------------- /vars/debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | process_exporter_dependencies: [] 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | go_arch_map: 3 | i386: '386' 4 | x86_64: 'amd64' 5 | aarch64: 'arm64' 6 | armv7l: 'armv6' 7 | armv6l: 'armv6' 8 | 9 | go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" 10 | 11 | process_exporter_system_user: "process-exp" 12 | process_exporter_system_group: "process-exp" 13 | -------------------------------------------------------------------------------- /vars/redhat-7.yml: -------------------------------------------------------------------------------- 1 | --- 2 | process_exporter_dependencies: 3 | - libselinux-python 4 | - policycoreutils-python 5 | -------------------------------------------------------------------------------- /vars/redhat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | process_exporter_dependencies: 3 | - python3-libselinux 4 | - python3-policycoreutils 5 | --------------------------------------------------------------------------------