Skip to content

Commit b4099c1

Browse files
committed
init
0 parents  commit b4099c1

30 files changed

+632
-0
lines changed

.ansible-lint

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
skip_list:
3+
- '204'

.github/lock.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
_extends: auto-maintenance

.github/stale.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
_extends: auto-maintenance

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.retry
2+
*.log
3+
.molecule
4+
.cache
5+
__pycache__/
6+
.pytest_cache
7+
.tox

.travis.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
sudo: required
3+
language: python
4+
python: 2.7
5+
cache: pip
6+
services:
7+
- docker
8+
env:
9+
- ANSIBLE=2.6
10+
- ANSIBLE=2.7
11+
- ANSIBLE=2.8
12+
matrix:
13+
fast_finish: true
14+
install:
15+
- pip install tox-travis git-semver
16+
script:
17+
- tox
18+
deploy:
19+
provider: script
20+
skip_cleanup: true
21+
script: .travis/releaser.sh
22+
on:
23+
branch: master
24+
branches:
25+
only:
26+
- master
27+
notifications:
28+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

.travis/releaser.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved
4+
# Permission to copy and modify is granted under the MIT license
5+
#
6+
# Script to automatically do a couple of things:
7+
# - generate a new tag according to semver (https://semver.org/)
8+
# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator
9+
# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler
10+
#
11+
# Tags are generated by searching for a keyword in last commit message. Keywords are:
12+
# - [patch] or [fix] to bump patch number
13+
# - [minor], [feature] or [feat] to bump minor number
14+
# - [major] or [breaking change] to bump major number
15+
# All keywords MUST be surrounded with square braces.
16+
#
17+
# Script uses git mechanisms for locking, so it can be used in parallel builds
18+
#
19+
# Requirements:
20+
# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo
21+
# - docker
22+
# - git-semver python package (pip install git-semver)
23+
24+
# Exit when latest commit is tagged
25+
[[ $(git tag --points-at) ]] && exit 0
26+
27+
# Some basic variables
28+
29+
GIT_USER="cloudalchemybot"
30+
ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
31+
PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
32+
GALAXY_URL="https://galaxy.ansible.com/${ORGANIZATION}/${PROJECT#ansible-}"
33+
34+
# Git config
35+
git config --global user.email "${GIT_MAIL}"
36+
git config --global user.name "${GIT_USER}"
37+
GIT_URL=$(git config --get remote.origin.url)
38+
GIT_URL=${GIT_URL#*//}
39+
40+
# Generate TAG
41+
GIT_TAG=none
42+
echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
43+
case "${TRAVIS_COMMIT_MESSAGE}" in
44+
*"[patch]"*|*"[fix]"* ) GIT_TAG=$(git semver --next-patch) ;;
45+
*"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;;
46+
*"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;;
47+
*) echo "Keyword not detected. Doing nothing" ;;
48+
esac
49+
if [ "$GIT_TAG" != "none" ]; then
50+
echo "Assigning new tag: $GIT_TAG"
51+
git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
52+
git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0
53+
fi
54+
55+
# Generate CHANGELOG.md
56+
git checkout master
57+
git pull
58+
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator:1.14.3 \
59+
-u "${ORGANIZATION}" -p "${PROJECT}" --token "${GH_TOKEN}" \
60+
--release-url "${GALAXY_URL}" \
61+
--unreleased-label "**Next release**" --no-compare-link
62+
63+
git add CHANGELOG.md
64+
git commit -m '[ci skip] Automatic changelog update'
65+
66+
git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0
67+
68+
# Sync changelog to github releases
69+
if [ "$GIT_TAG" != "none" ]; then
70+
docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}"
71+
fi

.yamllint

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends: default
2+
ignore: |
3+
.travis/
4+
.travis.yml
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

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
4+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

CONTRIBUTING.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Contributor Guideline
2+
3+
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!!
4+
5+
## Communication
6+
7+
### IRC
8+
9+
You can talk with us on #cloudalchemy channel on freenode.
10+
11+
### GitHub repositories
12+
13+
Much of the issues, goals and ideas are tracked in the respective projects in GitHub. Please use this channel to report bugs.
14+
15+
## git and GitHub
16+
17+
In order to contribute code please:
18+
19+
1. Fork the project on GitHub
20+
2. Clone the project
21+
3. Add changes (and tests)
22+
4. Commit and push
23+
5. Create a merge-request
24+
25+
To have your code merged, see the expectations listed below.
26+
27+
You can find a well-written guide [here](https://help.github.com/articles/fork-a-repo).
28+
29+
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.
30+
31+
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).
32+
33+
## Releases
34+
35+
We try to stick to semantic versioning and our releases are made by CI pipeline. It is done 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!):
36+
37+
* `[patch]`, `[fix]` - for PATCH version release
38+
* `[minor]`, `[feature]`, `[feat]` - for MINOR version release
39+
* `[major]`, `[breaking change]` - for MAJOR version release
40+
41+
## Changelog
42+
43+
Changelog is generateg automatically on every merged Pull Request and all information is taken from github issues, PRs and labels.
44+
45+
## Expectations
46+
47+
### Keep it simple
48+
49+
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).
50+
51+
### Be explicit
52+
53+
* Please avoid using nonsensical property and variable names.
54+
* Use self-describing attribute names for user configuration.
55+
* 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.
56+
57+
58+
### Add tests
59+
60+
Currently we are using two test scenarios located in [/molecule](molecule) directory. First ([default](molecule/default/molecule.yml)) one is testing default configuration without any additional variables, second one ([alternative](molecule/alternative/molecule.yml)) 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)).
61+
More information about:
62+
- [testinfra](http://testinfra.readthedocs.io/en/latest/index.html)
63+
- [molecule](https://molecule.readthedocs.io/en/latest/index.html)
64+
65+
### Follow best practices
66+
67+
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.
68+
69+
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.
70+
71+
Remember: Code is generally read much more often than written.
72+
73+
### Use Markdown
74+
75+
Wherever possible, please refrain from any other formats and stick to simple markdown.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.

README.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Ansible Role: process_exporter
2+
3+
[![Build Status](https://travis-ci.org/cloudalchemy/ansible-process_exporter.svg?branch=master)](https://travis-ci.org/cloudalchemy/ansible-process_exporter)
4+
[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)
5+
[![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.process_exporter-blue.svg)](https://galaxy.ansible.com/cloudalchemy/process_exporter/)
6+
[![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-process_exporter.svg)](https://github.com/cloudalchemy/ansible-process_exporter/tags)
7+
[![IRC](https://img.shields.io/badge/irc.freenode.net-%23cloudalchemy-yellow.svg)](https://kiwiirc.com/nextclient/#ircs://irc.freenode.net/#cloudalchemy)
8+
9+
## Description
10+
11+
Deploy [process_exporter](https://github.com/ncabatoff/process_exporter) using ansible.
12+
13+
## Requirements
14+
15+
- Ansible >= 2.5 (It might work on previous versions, but we cannot guarantee it)
16+
17+
## Role Variables
18+
19+
All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below.
20+
21+
| Name | Default Value | Description |
22+
| -------------- | ------------- | -----------------------------------|
23+
| `process_exporter_web_listen_address` | "0.0.0.0:9256" | Address on which process_exporter will listen |
24+
25+
## Example
26+
27+
### Playbook
28+
29+
Use it in a playbook as follows:
30+
```yaml
31+
- hosts: all
32+
roles:
33+
- cloudalchemy.process_exporter
34+
```
35+
36+
### Demo site
37+
38+
We provide 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/cloudalchemy/demo-site) and site is hosted on [DigitalOcean](https://digitalocean.com).
39+
40+
## Local Testing
41+
42+
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.
43+
We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:
44+
```sh
45+
pip install tox
46+
```
47+
To run tests on all ansible versions (WARNING: this can take some time)
48+
```sh
49+
tox
50+
```
51+
To run a custom molecule command on custom environment with only default test scenario:
52+
```sh
53+
tox -e py27-ansible25 -- molecule test -s default
54+
```
55+
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).
56+
57+
If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests.
58+
59+
## Travis CI
60+
61+
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.
62+
63+
## Contributing
64+
65+
See [contributor guideline](CONTRIBUTING.md).
66+
67+
## License
68+
69+
This project is licensed under MIT License. See [LICENSE](/LICENSE) for more details.

defaults/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
process_exporter_web_listen_address: "0.0.0.0:9256"

handlers/main.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: restart process_exporter
3+
become: true
4+
systemd:
5+
daemon_reload: true
6+
name: process_exporter
7+
state: restarted

meta/main.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
galaxy_info:
3+
author: Pawel Krupa
4+
description: Deploy process_exporter
5+
license: MIT
6+
min_ansible_version: 2.6
7+
platforms:
8+
- name: Ubuntu
9+
versions:
10+
- bionic
11+
- xenial
12+
- name: Debian
13+
versions:
14+
- jessie
15+
- stretch
16+
- name: EL
17+
versions:
18+
- 7
19+
- name: Fedora
20+
versions:
21+
- 30
22+
galaxy_tags:
23+
- monitoring
24+
25+
dependencies: []

molecule/default/create.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
- name: Create
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
7+
tasks:
8+
- name: Create molecule instance(s)
9+
docker_container:
10+
name: "{{ item.name }}"
11+
docker_host: "{{ item.docker_host | default('unix://var/run/docker.sock') }}"
12+
hostname: "{{ item.name }}"
13+
image: "{{ item.image }}"
14+
state: started
15+
recreate: false
16+
log_driver: json-file
17+
command: "{{ item.command | default(omit) }}"
18+
privileged: "{{ item.privileged | default(omit) }}"
19+
volumes: "{{ item.volumes | default(omit) }}"
20+
capabilities: "{{ item.capabilities | default(omit) }}"
21+
exposed_ports: "{{ item.exposed_ports | default(omit) }}"
22+
published_ports: "{{ item.published_ports | default(omit) }}"
23+
ulimits: "{{ item.ulimits | default(omit) }}"
24+
networks: "{{ item.networks | default(omit) }}"
25+
dns_servers: "{{ item.dns_servers | default(omit) }}"
26+
register: server
27+
with_items: "{{ molecule_yml.platforms }}"
28+
async: 7200
29+
poll: 0
30+
31+
- name: Wait for instance(s) creation to complete
32+
async_status:
33+
jid: "{{ item.ansible_job_id }}"
34+
register: docker_jobs
35+
until: docker_jobs.finished
36+
retries: 300
37+
with_items: "{{ server.results }}"

0 commit comments

Comments
 (0)