Skip to content

Commit 55332e1

Browse files
committed
initial commit
0 parents  commit 55332e1

File tree

16 files changed

+328
-0
lines changed

16 files changed

+328
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

.yamllint

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Based on ansible-lint config
3+
extends: default
4+
5+
rules:
6+
braces:
7+
max-spaces-inside: 1
8+
level: error
9+
brackets:
10+
max-spaces-inside: 1
11+
level: error
12+
colons:
13+
max-spaces-after: -1
14+
level: error
15+
commas:
16+
max-spaces-after: -1
17+
level: error
18+
comments: disable
19+
comments-indentation: disable
20+
document-start: disable
21+
empty-lines:
22+
max: 3
23+
level: error
24+
hyphens:
25+
level: error
26+
indentation: disable
27+
key-duplicates: enable
28+
line-length: disable
29+
new-line-at-end-of-file: disable
30+
new-lines:
31+
type: unix
32+
trailing-spaces: disable
33+
truthy: disable

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Anton Melekhin
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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Postgres Exporter
2+
=================
3+
4+
Ansible роль для установки, настройки и обновления [Postgres Exporter](https://github.com/prometheus-community/postgres_exporter).
5+
6+
Требования
7+
----------
8+
9+
- Поддерживаемая версия Ansible: 2.7 и выше.
10+
- `pywinrm` для подключения [Ansible через WinRM](https://docs.ansible.com/ansible/latest/user_guide/windows_winrm.html) (для Windows).
11+
- `gnu-tar` при использовании Mac в качестве управляющего хоста (`brew install gnu-tar`).
12+
- Список поддерживаемых платформ описан в файле метаданных роли.
13+
14+
Используемые переменные
15+
-----------------------
16+
17+
- `postgres_exporter_version` Версия Postgres Exporter для установки (default: `0.11.1`).
18+
- `postgres_exporter_package_name` Имя пакета.
19+
- `postgres_exporter_download_url` Ссылка на скачивание архива с приложением.
20+
- `postgres_exporter_user` Unix имя пользователя (default: `postgres`).
21+
- `postgres_exporter_group` Unix группа пользователя (default: `postgres`).
22+
- `postgres_exporter_install_path` Каталог, в который будет распакован бинарник (default: `/usr/local/bin`).
23+
- `postgres_exporter_data_source_name` Строка подключения к БД (default: `user=postgres host=/var/run/postgresql/ sslmode=disable`).
24+
- `postgres_exporter_extend_query_path` Путь до YAML файла содержащего дополнительные sql-запросы для записи метрик (default: `''`).
25+
- `postgres_exporter_log_level` Уровень логирования экспортера (default: `info`).
26+
27+
Зависимости
28+
-----------
29+
30+
Отсутствуют.
31+
32+
Пример использования
33+
--------------------
34+
35+
- Устанавливаем и настраиваем Postgres Exporter:
36+
37+
```yaml
38+
---
39+
- name: 'Setup Postgres Exporter'
40+
hosts: all
41+
42+
roles:
43+
- role: ansible-role-postgres-exporter
44+
```
45+
46+
Лицензия
47+
--------
48+
49+
MIT
50+
51+
Информация об авторе
52+
--------------------
53+
54+
Мелехин Антон.

defaults/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
# See available releases: https://github.com/prometheus-community/postgres_exporter/releases
3+
postgres_exporter_version: '0.11.1'
4+
postgres_exporter_package_name: 'postgres_exporter-{{ postgres_exporter_version }}.linux-{{ _postgres_exporter_architecture }}'
5+
postgres_exporter_download_url: 'https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ postgres_exporter_version }}/{{ postgres_exporter_package_name }}.tar.gz'
6+
7+
postgres_exporter_user: 'postgres'
8+
postgres_exporter_group: '{{ postgres_exporter_user }}'
9+
10+
postgres_exporter_install_path: '/usr/local/bin'
11+
12+
# See available environment variables: https://github.com/prometheus-community/postgres_exporter#environment-variables
13+
postgres_exporter_data_source_name: 'user=postgres host=/var/run/postgresql/ sslmode=disable'
14+
15+
# See available settings flags: https://github.com/prometheus-community/postgres_exporter#flags
16+
postgres_exporter_extend_query_path: ''
17+
postgres_exporter_log_level: 'info'

handlers/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: 'Restart Postgres Exporter'
3+
ansible.builtin.systemd:
4+
name: postgres_exporter
5+
state: restarted
6+
become: true

meta/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
galaxy_info:
3+
author: Melekhin Anton
4+
role_name: postgres_exporter
5+
namespace: antmelekhin
6+
description: An Ansible role for install, configure and update Postgres Exporter.
7+
8+
license: MIT
9+
10+
min_ansible_version: '2.7'
11+
12+
platforms:
13+
- name: EL
14+
versions:
15+
- '7'
16+
- '8'
17+
- name: Ubuntu
18+
versions:
19+
- 'bionic'
20+
- 'focal'
21+
22+
galaxy_tags:
23+
- monitoring
24+
- prometheus
25+
- postgres_exporter
26+
27+
dependencies: []

molecule/default/converge.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
5+
pre_tasks:
6+
- name: 'Update APT cache'
7+
ansible.builtin.apt:
8+
update_cache: true
9+
10+
roles:
11+
- role: geerlingguy.postgresql
12+
postgresql_users:
13+
- name: 'molecule'
14+
password: 'molecule'
15+
role_attr_flags: SUPERUSER
16+
postgresql_databases:
17+
- name: 'molecule'
18+
lc_collate: 'en_US.UTF-8'
19+
lc_ctype: 'en_US.UTF-8'
20+
encoding: 'UTF-8'
21+
template: 'template0'
22+
owner: 'molecule'
23+
24+
- role: ansible-role-postgres-exporter

molecule/default/molecule.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
enabled: true
5+
driver:
6+
name: docker
7+
lint: |
8+
set -e
9+
yamllint .
10+
platforms:
11+
- name: ubuntu-2004
12+
image: jrei/systemd-ubuntu:20.04
13+
published_ports:
14+
- 0.0.0.0:9187:9187/udp
15+
- 0.0.0.0:9187:9187/tcp
16+
volumes:
17+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
18+
privileged: true
19+
command: '/lib/systemd/systemd'
20+
provisioner:
21+
name: ansible
22+
verifier:
23+
name: ansible

molecule/default/requirements.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
roles:
3+
- src: geerlingguy.postgresql

0 commit comments

Comments
 (0)