Skip to content
This repository was archived by the owner on Nov 12, 2023. It is now read-only.

Commit fa83bb1

Browse files
committed
basic version
1 parent ac6ccc1 commit fa83bb1

26 files changed

+503
-186
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
# Change Log
22

3-
4-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018-2019 Pawel Krupa and <<AUTHOR>>
3+
Copyright (c) 2017-2018 Pawel Krupa and Roman Demachkovych
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,76 @@
1-
<p><img src="http://pngimg.com/uploads/skeleton/skeleton_PNG42642.png" alt="skeleton logo" title="graph" align="right" height="60" /></p>
1+
<p><img src="https://brand.systemd.io/assets/png/systemd-logomark.png" alt="systemd logo" title="systemd" align="right" height="60" /></p>
22

3-
# Cloud Alchemy Ansible Role Skeleton
3+
# Ansible Role: systemd exporter
44

5+
[![Build Status](https://travis-ci.com/cloudalchemy/ansible-systemd-exporter.svg?branch=master)](https://travis-ci.com/cloudalchemy/ansible-systemd-exporter)
56
[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)
7+
[![Ansible Role](https://img.shields.io/badge/ansible%20role-cloudalchemy.systemd_exporter-blue.svg)](https://galaxy.ansible.com/cloudalchemy/systemd-exporter/)
8+
[![GitHub tag](https://img.shields.io/github/tag/cloudalchemy/ansible-systemd-exporter.svg)](https://github.com/cloudalchemy/ansible-systemd-exporter/tags)
69

710
## Description
811

9-
Skeleton to create new ansible roles similar to other Cloud Alchemy roles.
12+
Deploy prometheus [systemd exporter](https://github.com/povilasv/systemd_exporter) using ansible.
1013

11-
## How to use it
14+
## Requirements
1215

13-
To create a new role, just follow a couple of easy steps:
14-
1. Clone this repo
15-
1. Open `create.sh` with your favorite editor
16-
1. Modify variables mentioned in that file
17-
1. Run `create.sh`
16+
- Ansible >= 2.7 (It might work on previous versions, but we cannot guarantee it)
17+
- gnu-tar on Mac deployer host (`brew install gnu-tar`)
1818

19-
## Result
19+
## Role Variables
2020

21-
After running `create.sh` it will convert this repo into a directory structure with everything needed to start
22-
developing new Cloud Alchemy ansible role.
21+
All variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below.
2322

24-
## Warnings
23+
| Name | Default Value | Description |
24+
| -------------- | ------------- | -----------------------------------|
25+
| `systemd_exporter_version` | 0.4.0 | SystemD exporter package version. Also accepts latest as parameter. |
26+
| `systemd_exporter_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes a directory where `systemd_exporter` binary is stored on host on which ansible is ran. This overrides `systemd_exporter_version` parameter |
27+
| `systemd_exporter_web_listen_address` | "0.0.0.0:9558" | Address on which systemd exporter will listen |
2528

26-
- Running `create.sh` deletes `.git` directory.
27-
- README.md file is overwritten with ROLE_README.md
29+
## Example
30+
31+
### Playbook
32+
33+
Use it in a playbook as follows:
34+
```yaml
35+
- hosts: all
36+
roles:
37+
- cloudalchemy.systemd-exporter
38+
```
39+
40+
### Demo site
41+
42+
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).
43+
44+
## Local Testing
45+
46+
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.
47+
We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:
48+
```sh
49+
pip3 install tox
50+
```
51+
To run tests on all ansible versions (WARNING: this can take some time)
52+
```sh
53+
tox
54+
```
55+
To run a custom molecule command on custom environment with only default test scenario:
56+
```sh
57+
tox -e py35-ansible28 -- molecule test -s default
58+
```
59+
For more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).
60+
61+
If you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests.
62+
63+
## Travis CI
64+
65+
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.
66+
67+
## Contributing
68+
69+
See [contributor guideline](CONTRIBUTING.md).
70+
71+
## Troubleshooting
72+
73+
See [troubleshooting](TROUBLESHOOTING.md).
2874

2975
## License
3076

ROLE_README.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

create.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

defaults/main.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
---
2-
<<APPLICATION>>_web_listen_address: "0.0.0.0:<<PORT>>"
2+
systemd_exporter_version: 0.4.0
3+
systemd_exporter_binary_local_dir: ""
4+
systemd_exporter_web_listen_address: "0.0.0.0:9558"
5+
6+
systemd_exporter_enabled_collectors:
7+
- systemd
8+
- textfile:
9+
directory: "{{ systemd_exporter_textfile_dir }}"
10+
# - filesystem:
11+
# ignored-mount-points: "^/(sys|proc|dev)($|/)"
12+
# ignored-fs-types: "^(sys|proc|auto)fs$"

handlers/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
- name: restart <<APPLICATION>>
2+
- name: restart systemd_exporter
33
become: true
44
systemd:
55
daemon_reload: true
6-
name: <<APPLICATION>>
6+
name: systemd_exporter
77
state: restarted

meta/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
galaxy_info:
3-
author: <<AUTHOR>>
4-
description: Deploy <<APPLICATION>>
5-
role_name: <<APPLICATION>>
3+
author: Pawel Krupa
4+
description: Prometheus SystemD Exporter
65
license: MIT
76
company: none
87
min_ansible_version: 2.7
@@ -25,5 +24,9 @@ galaxy_info:
2524
- 31
2625
galaxy_tags:
2726
- monitoring
27+
- prometheus
28+
- exporter
29+
- metrics
30+
- systemd
2831

2932
dependencies: []

molecule/alternative/playbook.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
2-
- hosts: all
2+
- name: Run role
3+
hosts: all
34
any_errors_fatal: true
45
roles:
5-
- ansible-<<APPLICATION>>
6-
vars: []
6+
- ansible-systemd-exporter
7+
vars:
8+
systemd_exporter_binary_local_dir: "/tmp/systemd_exporter-linux-amd64"
9+
systemd_exporter_web_listen_address: "127.0.0.1:8080"

molecule/alternative/prepare.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
---
22
- name: Prepare
3-
hosts: all
3+
hosts: localhost
44
gather_facts: false
5-
tasks: []
5+
vars:
6+
go_arch: amd64
7+
node_exporter_version: 1.0.0
8+
tasks:
9+
- name: Download node_exporter binary to local folder
10+
become: false
11+
get_url:
12+
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
13+
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
14+
register: _download_binary
15+
until: _download_binary is succeeded
16+
retries: 5
17+
delay: 2
18+
run_once: true
19+
check_mode: false
20+
21+
- name: Unpack node_exporter binary
22+
become: false
23+
unarchive:
24+
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
25+
dest: "/tmp"
26+
creates: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}/node_exporter"
27+
run_once: true
28+
check_mode: false
29+
30+
- name: link to node_exporter binaries directory
31+
become: false
32+
file:
33+
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-amd64"
34+
dest: "/tmp/node_exporter-linux-amd64"
35+
state: link
36+
run_once: true
37+
check_mode: false
38+
39+
- name: install pyOpenSSL for certificate generation
40+
pip:
41+
name: "pyOpenSSL"
42+
43+
- name: Create private key
44+
openssl_privatekey:
45+
path: "/tmp/tls.key"
46+
47+
- name: Create CSR
48+
openssl_csr:
49+
path: "/tmp/tls.csr"
50+
privatekey_path: "/tmp/tls.key"
51+
52+
- name: Create certificate
53+
openssl_certificate:
54+
path: "/tmp/tls.cert"
55+
csr_path: "/tmp/tls.csr"
56+
privatekey_path: "/tmp/tls.key"
57+
provider: selfsigned

0 commit comments

Comments
 (0)