Compare commits

...

No commits in common. "main" and "docs" have entirely different histories.
main ... docs

41 changed files with 480 additions and 1511 deletions

View File

@ -1,161 +0,0 @@
local PipelineLinting = {
kind: 'pipeline',
name: 'linting',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'ansible-later',
image: 'thegeeklab/ansible-later',
commands: [
'ansible-later',
],
},
{
name: 'python-format',
image: 'python:3.11',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -qq yapf',
'[ -z "$(find . -type f -name *.py)" ] || (yapf -rd ./)',
],
},
{
name: 'python-flake8',
image: 'python:3.11',
environment: {
PY_COLORS: 1,
},
commands: [
'pip install -qq flake8',
'flake8',
],
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineDeployment(scenario='centos7') = {
kind: 'pipeline',
name: 'testing-' + scenario,
platform: {
os: 'linux',
arch: 'amd64',
},
concurrency: {
limit: 1,
},
workspace: {
base: '/drone/src',
path: '${DRONE_REPO_NAME}',
},
steps: [
{
name: 'ansible-molecule',
image: 'thegeeklab/molecule:4',
environment: {
HCLOUD_TOKEN: { from_secret: 'hcloud_token' },
},
commands: [
'molecule test -s ' + scenario,
],
},
],
depends_on: [
'linting',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineDocumentation = {
kind: 'pipeline',
name: 'documentation',
platform: {
os: 'linux',
arch: 'amd64',
},
steps: [
{
name: 'generate',
image: 'thegeeklab/ansible-doctor',
environment: {
ANSIBLE_DOCTOR_LOG_LEVEL: 'INFO',
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true,
ANSIBLE_DOCTOR_EXCLUDE_FILES: 'molecule/',
ANSIBLE_DOCTOR_TEMPLATE: 'hugo-book',
ANSIBLE_DOCTOR_ROLE_NAME: '${DRONE_REPO_NAME#*.}',
ANSIBLE_DOCTOR_OUTPUT_DIR: '_docs/',
},
},
{
name: 'publish',
image: 'plugins/gh-pages',
settings: {
remote_url: 'https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}',
netrc_machine: 'gitea.rknet.org',
username: { from_secret: 'gitea_username' },
password: { from_secret: 'gitea_token' },
pages_directory: '_docs/',
target_branch: 'docs',
},
when: {
ref: ['refs/heads/main'],
},
},
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
depends_on: [
'testing-centos7',
'testing-rocky8',
],
};
local PipelineNotification = {
kind: 'pipeline',
name: 'notification',
platform: {
os: 'linux',
arch: 'amd64',
},
clone: {
disable: true,
},
steps: [
{
name: 'matrix',
image: 'thegeeklab/drone-matrix',
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}',
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
},
],
depends_on: [
'documentation',
],
trigger: {
status: ['success', 'failure'],
ref: ['refs/heads/main', 'refs/tags/**'],
},
};
[
PipelineLinting,
PipelineDeployment(scenario='centos7'),
PipelineDeployment(scenario='rocky8'),
PipelineDocumentation,
PipelineNotification,
]

View File

@ -1,187 +0,0 @@
---
kind: pipeline
name: linting
platform:
os: linux
arch: amd64
steps:
- name: ansible-later
image: thegeeklab/ansible-later
commands:
- ansible-later
- name: python-format
image: python:3.11
commands:
- pip install -qq yapf
- "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)"
environment:
PY_COLORS: 1
- name: python-flake8
image: python:3.11
commands:
- pip install -qq flake8
- flake8
environment:
PY_COLORS: 1
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
kind: pipeline
name: testing-centos7
platform:
os: linux
arch: amd64
concurrency:
limit: 1
workspace:
base: /drone/src
path: ${DRONE_REPO_NAME}
steps:
- name: ansible-molecule
image: thegeeklab/molecule:4
commands:
- molecule test -s centos7
environment:
HCLOUD_TOKEN:
from_secret: hcloud_token
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- linting
---
kind: pipeline
name: testing-rocky8
platform:
os: linux
arch: amd64
concurrency:
limit: 1
workspace:
base: /drone/src
path: ${DRONE_REPO_NAME}
steps:
- name: ansible-molecule
image: thegeeklab/molecule:4
commands:
- molecule test -s rocky8
environment:
HCLOUD_TOKEN:
from_secret: hcloud_token
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- linting
---
kind: pipeline
name: documentation
platform:
os: linux
arch: amd64
steps:
- name: generate
image: thegeeklab/ansible-doctor
environment:
ANSIBLE_DOCTOR_EXCLUDE_FILES: molecule/
ANSIBLE_DOCTOR_FORCE_OVERWRITE: true
ANSIBLE_DOCTOR_LOG_LEVEL: INFO
ANSIBLE_DOCTOR_OUTPUT_DIR: _docs/
ANSIBLE_DOCTOR_ROLE_NAME: ${DRONE_REPO_NAME#*.}
ANSIBLE_DOCTOR_TEMPLATE: hugo-book
- name: publish
image: plugins/gh-pages
settings:
netrc_machine: gitea.rknet.org
pages_directory: _docs/
password:
from_secret: gitea_token
remote_url: https://gitea.rknet.org/ansible/${DRONE_REPO_NAME}
target_branch: docs
username:
from_secret: gitea_username
when:
ref:
- refs/heads/main
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- testing-centos7
- testing-rocky8
---
kind: pipeline
name: notification
platform:
os: linux
arch: amd64
clone:
disable: true
steps:
- name: matrix
image: thegeeklab/drone-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}"
username:
from_secret: matrix_username
trigger:
ref:
- refs/heads/main
- refs/tags/**
status:
- success
- failure
depends_on:
- documentation
---
kind: signature
hmac: 5d1abaa95a1690c0e03618cf801cda33faf59da3e171fe0c71eca6961e822837
...

13
.gitignore vendored
View File

@ -1,13 +0,0 @@
# ---> Ansible
*.retry
plugins
library
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# ---> Docs
/_docs

View File

@ -1,19 +0,0 @@
---
ansible:
custom_modules:
- iptables_raw
- openssl_pkcs12
- proxmox_kvm
- ucr
- corenetworks_dns
- corenetworks_token
rules:
exclude_files:
- molecule/
- "LICENSE*"
- "**/*.md"
- "**/*.ini"
exclude_filter:
- LINT0009

View File

@ -1 +0,0 @@
.drone*

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
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 (including the next
paragraph) 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.

View File

@ -1,10 +0,0 @@
# xoxys.prometheus
[![Build Status](https://img.shields.io/drone/build/ansible/xoxys.prometheus?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.prometheus)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
Deploy [Prometheus](https://prometheus.io/) monitoring system. You can find the full documentation at [https://galaxy.geekdocs.de](https://galaxy.geekdocs.de/roles/cloud/prometheus/).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

View File

@ -1,138 +0,0 @@
---
prometheus_version: 2.27.0
prometheus_user: "prometheus_adm"
prometheus_user_home: "/home/{{ prometheus_user }}"
prometheus_user_comment: Prometheus
prometheus_group: "{{ prometheus_user }}"
prometheus_extra_groups: []
prometheus_packages:
- tar
prometheus_base_dir: "/opt/prometheus"
prometheus_config_dir: "{{ prometheus_base_dir }}/conf"
prometheus_rules_dir: "{{ prometheus_config_dir }}/rules"
prometheus_file_sd_dir: "{{ prometheus_config_dir }}/file_sd"
prometheus_data_dir: "{{ prometheus_base_dir }}/data"
prometheus_read_only_dirs: []
prometheus_web_bind_ip: 127.0.0.1
prometheus_web_bind_port: 61000
prometheus_web_external_url: "http://localhost:61000/"
prometheus_web_tls_enabled: False
prometheus_web_tls_cert_path: "{{ prometheus_base_dir }}/tls/certs/mycert.pem"
prometheus_web_tls_key_path: "{{ prometheus_base_dir }}/tls/private/mykey.pem"
prometheus_web_tls_cert_source: mycert.pem
prometheus_web_tls_key_source: mykey.pem
# @var prometheus_web_http_server:description: See official [documentation](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).
# @var prometheus_web_http_server: $ "_unset_"
# @var prometheus_web_basic_auth_users:description: See official [documentation](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).
# @var prometheus_web_basic_auth_users: $ "_unset_"
prometheus_log_level: error
prometheus_storage_retention: "30d"
prometheus_storage_retention_size: "0"
# @var prometheus_storage_retention_size:description: __[EXPERIMENTAL]__ Maximum number of bytes that can be stored for blocks.
# Units supported: KB, MB, GB, TB, PB.
# @end
prometheus_config_flags_extra: []
# @var prometheus_config_flags_extra:example: >
# prometheus_config_flags_extra:
# - name: alertmanager.timeout
# value: 10s
# @end
prometheus_alertmanager_config: []
# @var prometheus_alertmanager_config:example: >
# 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"
# @end
prometheus_alert_relabel_configs: []
# @var prometheus_alert_relabel_configs:example: >
# prometheus_alert_relabel_configs:
# - action: labeldrop
# regex: replica
prometheus_global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
prometheus_remote_write: []
# @var prometheus_remote_write:example: >
# prometheus_remote_write:
# - url: https://dev.kausal.co/prom/push
# basic_auth:
# password: FOO
prometheus_remote_read: []
# @var prometheus_remote_read:example: >
# prometheus_remote_read:
# - url: https://demo.cloudalchemy.org:9201/read
# basic_auth:
# password: FOO
# @end
prometheus_external_labels:
environment: "{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname) }}"
prometheus_targets: []
# @var prometheus_targets:example: >
# prometheus_targets:
# - name: node
# config:
# - targets:
# - localhost:9100
# labels:
# env: test
# @end
prometheus_scrape_configs:
- job_name: "prometheus"
metrics_path: "{{ prometheus_web_external_url | urlsplit('path') if (prometheus_web_external_url | urlsplit('path')) | length > 1 else '' }}/metrics"
static_configs:
- targets:
- "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:61000"
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.
This alert is always firing. There are integrations with various notification
mechanisms that send a notification when this alert is not firing anymore.
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 %}"
prometheus_alert_rules_extra: []

View File

@ -1,18 +0,0 @@
---
- name: Restart Prometheus Service
service:
name: prometheus
state: restarted
daemon_reload: yes
enabled: yes
listen: __prometheus_restart
become: True
become_user: root
- name: Reload Prometheus Service
service:
name: prometheus
state: reloaded
listen: __prometheus_reload
become: True
become_user: root

480
index.md Normal file
View File

@ -0,0 +1,480 @@
---
title: prometheus
type: docs
---
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.prometheus) [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.prometheus?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.prometheus) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.prometheus/src/branch/main/LICENSE)
Deploy [Prometheus](https://prometheus.io/) monitoring system.
<!--more-->
- [Default Variables](#default-variables)
- [prometheus_alert_relabel_configs](#prometheus_alert_relabel_configs)
- [prometheus_alert_rules](#prometheus_alert_rules)
- [prometheus_alert_rules_extra](#prometheus_alert_rules_extra)
- [prometheus_alert_rules_files](#prometheus_alert_rules_files)
- [prometheus_alertmanager_config](#prometheus_alertmanager_config)
- [prometheus_base_dir](#prometheus_base_dir)
- [prometheus_config_dir](#prometheus_config_dir)
- [prometheus_config_flags_extra](#prometheus_config_flags_extra)
- [prometheus_data_dir](#prometheus_data_dir)
- [prometheus_external_labels](#prometheus_external_labels)
- [prometheus_extra_groups](#prometheus_extra_groups)
- [prometheus_file_sd_dir](#prometheus_file_sd_dir)
- [prometheus_global](#prometheus_global)
- [prometheus_group](#prometheus_group)
- [prometheus_log_level](#prometheus_log_level)
- [prometheus_packages](#prometheus_packages)
- [prometheus_read_only_dirs](#prometheus_read_only_dirs)
- [prometheus_remote_read](#prometheus_remote_read)
- [prometheus_remote_write](#prometheus_remote_write)
- [prometheus_rules_dir](#prometheus_rules_dir)
- [prometheus_scrape_configs](#prometheus_scrape_configs)
- [prometheus_static_targets_files](#prometheus_static_targets_files)
- [prometheus_storage_retention](#prometheus_storage_retention)
- [prometheus_storage_retention_size](#prometheus_storage_retention_size)
- [prometheus_targets](#prometheus_targets)
- [prometheus_user](#prometheus_user)
- [prometheus_user_comment](#prometheus_user_comment)
- [prometheus_user_home](#prometheus_user_home)
- [prometheus_version](#prometheus_version)
- [prometheus_web_basic_auth_users](#prometheus_web_basic_auth_users)
- [prometheus_web_bind_ip](#prometheus_web_bind_ip)
- [prometheus_web_bind_port](#prometheus_web_bind_port)
- [prometheus_web_external_url](#prometheus_web_external_url)
- [prometheus_web_http_server](#prometheus_web_http_server)
- [prometheus_web_tls_cert_path](#prometheus_web_tls_cert_path)
- [prometheus_web_tls_cert_source](#prometheus_web_tls_cert_source)
- [prometheus_web_tls_enabled](#prometheus_web_tls_enabled)
- [prometheus_web_tls_key_path](#prometheus_web_tls_key_path)
- [prometheus_web_tls_key_source](#prometheus_web_tls_key_source)
- [Discovered Tags](#discovered-tags)
- [Dependencies](#dependencies)
---
## Default Variables
### prometheus_alert_relabel_configs
#### Default value
```YAML
prometheus_alert_relabel_configs: []
```
#### Example usage
```YAML
prometheus_alert_relabel_configs:
- action: labeldrop
regex: replica
```
### prometheus_alert_rules
#### Default value
```YAML
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.
This alert is always firing. There are integrations with various notification
mechanisms that send a notification when this alert is not firing anymore.
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 %}'
```
### prometheus_alert_rules_extra
#### Default value
```YAML
prometheus_alert_rules_extra: []
```
### prometheus_alert_rules_files
#### Default value
```YAML
prometheus_alert_rules_files:
- prometheus/rules/*.rules
```
### prometheus_alertmanager_config
#### Default value
```YAML
prometheus_alertmanager_config: []
```
#### Example usage
```YAML
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_base_dir
#### Default value
```YAML
prometheus_base_dir: /opt/prometheus
```
### prometheus_config_dir
#### Default value
```YAML
prometheus_config_dir: '{{ prometheus_base_dir }}/conf'
```
### prometheus_config_flags_extra
#### Default value
```YAML
prometheus_config_flags_extra: []
```
#### Example usage
```YAML
prometheus_config_flags_extra:
- name: alertmanager.timeout
value: 10s
```
### prometheus_data_dir
#### Default value
```YAML
prometheus_data_dir: '{{ prometheus_base_dir }}/data'
```
### prometheus_external_labels
#### Default value
```YAML
prometheus_external_labels:
environment: '{{ ansible_fqdn | default(ansible_host) | default(inventory_hostname)
}}'
```
### prometheus_extra_groups
#### Default value
```YAML
prometheus_extra_groups: []
```
### prometheus_file_sd_dir
#### Default value
```YAML
prometheus_file_sd_dir: '{{ prometheus_config_dir }}/file_sd'
```
### prometheus_global
#### Default value
```YAML
prometheus_global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
```
### prometheus_group
#### Default value
```YAML
prometheus_group: '{{ prometheus_user }}'
```
### prometheus_log_level
#### Default value
```YAML
prometheus_log_level: error
```
### prometheus_packages
#### Default value
```YAML
prometheus_packages:
- tar
```
### prometheus_read_only_dirs
#### Default value
```YAML
prometheus_read_only_dirs: []
```
### prometheus_remote_read
#### Default value
```YAML
prometheus_remote_read: []
```
#### Example usage
```YAML
prometheus_remote_read:
- url: https://demo.cloudalchemy.org:9201/read
basic_auth:
password: FOO
```
### prometheus_remote_write
#### Default value
```YAML
prometheus_remote_write: []
```
#### Example usage
```YAML
prometheus_remote_write:
- url: https://dev.kausal.co/prom/push
basic_auth:
password: FOO
```
### prometheus_rules_dir
#### Default value
```YAML
prometheus_rules_dir: '{{ prometheus_config_dir }}/rules'
```
### prometheus_scrape_configs
#### Default value
```YAML
prometheus_scrape_configs:
- job_name: prometheus
metrics_path: "{{ prometheus_web_external_url | urlsplit('path') if (prometheus_web_external_url\
\ | urlsplit('path')) | length > 1 else '' }}/metrics"
static_configs:
- targets:
- "{{ ansible_fqdn | default(ansible_host) | default('localhost') }}:61000"
```
### prometheus_static_targets_files
#### Default value
```YAML
prometheus_static_targets_files:
- prometheus/targets/*.yml
- prometheus/targets/*.json
```
### prometheus_storage_retention
#### Default value
```YAML
prometheus_storage_retention: 30d
```
### prometheus_storage_retention_size
__[EXPERIMENTAL]__ Maximum number of bytes that can be stored for blocks.
#### Default value
```YAML
prometheus_storage_retention_size: '0'
```
### prometheus_targets
#### Default value
```YAML
prometheus_targets: []
```
#### Example usage
```YAML
prometheus_targets:
- name: node
config:
- targets:
- localhost:9100
labels:
env: test
```
### prometheus_user
#### Default value
```YAML
prometheus_user: prometheus_adm
```
### prometheus_user_comment
#### Default value
```YAML
prometheus_user_comment: Prometheus
```
### prometheus_user_home
#### Default value
```YAML
prometheus_user_home: /home/{{ prometheus_user }}
```
### prometheus_version
#### Default value
```YAML
prometheus_version: 2.27.0
```
### prometheus_web_basic_auth_users
See official [documentation](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).
#### Default value
```YAML
prometheus_web_basic_auth_users: _unset_
```
### prometheus_web_bind_ip
#### Default value
```YAML
prometheus_web_bind_ip: 127.0.0.1
```
### prometheus_web_bind_port
#### Default value
```YAML
prometheus_web_bind_port: 61000
```
### prometheus_web_external_url
#### Default value
```YAML
prometheus_web_external_url: http://localhost:61000/
```
### prometheus_web_http_server
See official [documentation](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md).
#### Default value
```YAML
prometheus_web_http_server: _unset_
```
### prometheus_web_tls_cert_path
#### Default value
```YAML
prometheus_web_tls_cert_path: '{{ prometheus_base_dir }}/tls/certs/mycert.pem'
```
### prometheus_web_tls_cert_source
#### Default value
```YAML
prometheus_web_tls_cert_source: mycert.pem
```
### prometheus_web_tls_enabled
#### Default value
```YAML
prometheus_web_tls_enabled: false
```
### prometheus_web_tls_key_path
#### Default value
```YAML
prometheus_web_tls_key_path: '{{ prometheus_base_dir }}/tls/private/mykey.pem'
```
### prometheus_web_tls_key_source
#### Default value
```YAML
prometheus_web_tls_key_source: mykey.pem
```
## Discovered Tags
tls_renewal
: &nbsp;
## Dependencies
None.

View File

@ -1,23 +0,0 @@
# Standards: 0.2
---
galaxy_info:
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
author: "Robert Kaussow <mail@thegeeklab.de>"
namespace: xoxys
role_name: prometheus
# @meta description: >
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.prometheus)
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.prometheus?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.prometheus)
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.prometheus/src/branch/main/LICENSE)
#
# Deploy [Prometheus](https://prometheus.io/) monitoring system.
# @end
description: Deploy Prometheus monitoring system
license: MIT
min_ansible_version: 2.10
platforms:
- name: EL
versions:
- 7
galaxy_tags: []
dependencies: []

View File

@ -1,28 +0,0 @@
---
- name: Converge
hosts: all
vars:
prometheus_config_flags_extra:
- name: alertmanager.timeout
value: 10s
prometheus_alertmanager_config:
- scheme: https
path_prefix: alertmanager/
basic_auth:
username: user
password: pass
static_configs:
- targets:
- "127.0.0.1:9093"
prometheus_alert_relabel_configs:
- action: labeldrop
regex: replica
prometheus_targets:
- name: node
config:
- targets:
- localhost:9100
labels:
env: test
roles:
- role: xoxys.prometheus

View File

@ -1,120 +0,0 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ssh_port: 22
ssh_user: root
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
tasks:
- name: Create SSH key
user:
name: "{{ lookup('env', 'USER') }}"
generate_ssh_key: true
ssh_key_file: "{{ ssh_path }}"
force: true
register: generated_ssh_key
- name: Register the SSH key name
set_fact:
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
- name: Register SSH key for test instance(s)
hcloud_ssh_key:
name: "{{ ssh_key_name }}"
public_key: "{{ generated_ssh_key.ssh_public_key }}"
state: present
- name: Create molecule instance(s)
hcloud_server:
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
ssh_keys:
- "{{ ssh_key_name }}"
image: "{{ item.image }}"
location: "{{ item.location | default(omit) }}"
datacenter: "{{ item.datacenter | default(omit) }}"
user_data: "{{ item.user_data | default(omit) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: present
register: server
loop: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0
- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- name: Create volume(s)
hcloud_volume:
name: "{{ item.name }}"
server: "{{ item.name }}"
location: "{{ item.location | default(omit) }}"
size: "{{ item.volume_size | default(10) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "present"
loop: "{{ molecule_yml.platforms }}"
when: item.volume | default(False) | bool
register: volumes
async: 7200
poll: 0
- name: Wait for volume(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
# Mandatory configuration for Molecule to function.
- name: Populate instance config dict
set_fact:
instance_conf_dict:
{
"instance": "{{ item.hcloud_server.name }}",
"ssh_key_name": "{{ ssh_key_name }}",
"address": "{{ item.hcloud_server.ipv4_address }}",
"user": "{{ ssh_user }}",
"port": "{{ ssh_port }}",
"identity_file": "{{ ssh_path }}",
"volume": "{{ item.item.item.volume | default(False) | bool }}",
}
loop: "{{ hetzner_jobs.results }}"
register: instance_config_dict
when: server.changed | bool
- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
- name: Wait for SSH
wait_for:
port: "{{ ssh_port }}"
host: "{{ item.address }}"
search_regex: SSH
delay: 10
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
- name: Wait for VM to settle down
pause:
seconds: 30

View File

@ -1,78 +0,0 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
- name: Check existing instance config file
stat:
path: "{{ molecule_instance_config }}"
register: cfg
- name: Populate the instance config
set_fact:
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
- name: Destroy molecule instance(s)
hcloud_server:
name: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: absent
register: server
loop: "{{ instance_conf }}"
async: 7200
poll: 0
- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- pause:
seconds: 5
- name: Destroy volume(s)
hcloud_volume:
name: "{{ item.instance }}"
server: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "absent"
register: volumes
loop: "{{ instance_conf }}"
when: item.volume | default(False) | bool
async: 7200
poll: 0
- name: Wait for volume(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
- name: Remove registered SSH key
hcloud_ssh_key:
name: "{{ instance_conf[0].ssh_key_name }}"
state: absent
when: (instance_conf | default([])) | length > 0
# Mandatory configuration for Molecule to function.
- name: Populate instance config
set_fact:
instance_conf: {}
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool

View File

@ -1,24 +0,0 @@
---
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
env:
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
driver:
name: delegated
platforms:
- name: centos7-prometheus
image: centos-7
server_type: cx11
lint: |
/usr/local/bin/flake8
provisioner:
name: ansible
env:
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
log: False
verifier:
name: testinfra

View File

@ -1,15 +0,0 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Bootstrap python for Ansible
raw: |
command -v python3 python || (
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
echo "Warning: Python not boostrapped due to unknown platform."
)
become: true
changed_when: false

View File

@ -1,18 +0,0 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_prometheus_running_and_enabled(host):
prometheus = host.service("prometheus")
assert prometheus.is_running
assert prometheus.is_enabled
def test_prometheus_socket(host):
# Verify the socket is listening for HTTP traffic
assert host.socket("tcp://127.0.0.1:61000").is_listening

View File

@ -1 +0,0 @@
rocky8

View File

@ -1,3 +0,0 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning

View File

@ -1,6 +0,0 @@
---
collections:
- name: https://gitea.rknet.org/ansible/xoxys.general/releases/download/v2.1.1/xoxys-general-2.1.1.tar.gz
- name: community.general
roles: []

View File

@ -1,28 +0,0 @@
---
- name: Converge
hosts: all
vars:
prometheus_config_flags_extra:
- name: alertmanager.timeout
value: 10s
prometheus_alertmanager_config:
- scheme: https
path_prefix: alertmanager/
basic_auth:
username: user
password: pass
static_configs:
- targets:
- "127.0.0.1:9093"
prometheus_alert_relabel_configs:
- action: labeldrop
regex: replica
prometheus_targets:
- name: node
config:
- targets:
- localhost:9100
labels:
env: test
roles:
- role: xoxys.prometheus

View File

@ -1,120 +0,0 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ssh_port: 22
ssh_user: root
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
tasks:
- name: Create SSH key
user:
name: "{{ lookup('env', 'USER') }}"
generate_ssh_key: true
ssh_key_file: "{{ ssh_path }}"
force: true
register: generated_ssh_key
- name: Register the SSH key name
set_fact:
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
- name: Register SSH key for test instance(s)
hcloud_ssh_key:
name: "{{ ssh_key_name }}"
public_key: "{{ generated_ssh_key.ssh_public_key }}"
state: present
- name: Create molecule instance(s)
hcloud_server:
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
ssh_keys:
- "{{ ssh_key_name }}"
image: "{{ item.image }}"
location: "{{ item.location | default(omit) }}"
datacenter: "{{ item.datacenter | default(omit) }}"
user_data: "{{ item.user_data | default(omit) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: present
register: server
loop: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0
- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- name: Create volume(s)
hcloud_volume:
name: "{{ item.name }}"
server: "{{ item.name }}"
location: "{{ item.location | default(omit) }}"
size: "{{ item.volume_size | default(10) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "present"
loop: "{{ molecule_yml.platforms }}"
when: item.volume | default(False) | bool
register: volumes
async: 7200
poll: 0
- name: Wait for volume(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
# Mandatory configuration for Molecule to function.
- name: Populate instance config dict
set_fact:
instance_conf_dict:
{
"instance": "{{ item.hcloud_server.name }}",
"ssh_key_name": "{{ ssh_key_name }}",
"address": "{{ item.hcloud_server.ipv4_address }}",
"user": "{{ ssh_user }}",
"port": "{{ ssh_port }}",
"identity_file": "{{ ssh_path }}",
"volume": "{{ item.item.item.volume | default(False) | bool }}",
}
loop: "{{ hetzner_jobs.results }}"
register: instance_config_dict
when: server.changed | bool
- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
- name: Wait for SSH
wait_for:
port: "{{ ssh_port }}"
host: "{{ item.address }}"
search_regex: SSH
delay: 10
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
- name: Wait for VM to settle down
pause:
seconds: 30

View File

@ -1,78 +0,0 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
- name: Check existing instance config file
stat:
path: "{{ molecule_instance_config }}"
register: cfg
- name: Populate the instance config
set_fact:
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
- name: Destroy molecule instance(s)
hcloud_server:
name: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: absent
register: server
loop: "{{ instance_conf }}"
async: 7200
poll: 0
- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
loop: "{{ server.results }}"
- pause:
seconds: 5
- name: Destroy volume(s)
hcloud_volume:
name: "{{ item.instance }}"
server: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: "absent"
register: volumes
loop: "{{ instance_conf }}"
when: item.volume | default(False) | bool
async: 7200
poll: 0
- name: Wait for volume(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_volumes
until: hetzner_volumes.finished
retries: 300
when: volumes.changed
loop: "{{ volumes.results }}"
- name: Remove registered SSH key
hcloud_ssh_key:
name: "{{ instance_conf[0].ssh_key_name }}"
state: absent
when: (instance_conf | default([])) | length > 0
# Mandatory configuration for Molecule to function.
- name: Populate instance config
set_fact:
instance_conf: {}
- name: Dump instance config
copy:
content: |
# Molecule managed
{{ instance_conf | to_nice_yaml(indent=2) }}
dest: "{{ molecule_instance_config }}"
when: server.changed | bool

View File

@ -1,24 +0,0 @@
---
dependency:
name: galaxy
options:
role-file: molecule/requirements.yml
requirements-file: molecule/requirements.yml
env:
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
driver:
name: delegated
platforms:
- name: rocky8-prometheus
image: rocky-8
server_type: cx11
lint: |
/usr/local/bin/flake8
provisioner:
name: ansible
env:
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
log: False
verifier:
name: testinfra

View File

@ -1,15 +0,0 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Bootstrap python for Ansible
raw: |
command -v python3 python || (
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
echo "Warning: Python not boostrapped due to unknown platform."
)
become: true
changed_when: false

View File

@ -1,18 +0,0 @@
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
def test_prometheus_running_and_enabled(host):
prometheus = host.service("prometheus")
assert prometheus.is_running
assert prometheus.is_enabled
def test_prometheus_socket(host):
# Verify the socket is listening for HTTP traffic
assert host.socket("tcp://127.0.0.1:61000").is_listening

View File

@ -1,12 +0,0 @@
[flake8]
ignore = D100, D101, D102, D103, D105, D107, E402, W503
max-line-length = 99
inline-quotes = double
exclude = .git,.tox,__pycache__,build,dist,tests,*.pyc,*.egg-info,.cache,.eggs,env*
[yapf]
based_on_style = google
column_limit = 99
dedent_closing_brackets = true
coalesce_brackets = true
split_before_logical_operator = true

View File

@ -1,6 +0,0 @@
---
- include_tasks: prepare.yml
- import_tasks: tls.yml
when: prometheus_web_tls_enabled | bool
tags: tls_renewal
- include_tasks: setup.yml

View File

@ -1,36 +0,0 @@
---
- name: Set current prometheus version
set_fact:
prometheus_current_version: "{{ (ansible_local.prometheus | default (dict(version='0.0.0')))['version'] }}"
- debug:
msg: Current version is '{{ prometheus_current_version }}'
- block:
- name: Create group '{{ prometheus_group }}'
group:
name: "{{ prometheus_group }}"
state: present
- name: Create user '{{ prometheus_user }}'
user:
comment: "{{ prometheus_user_comment }}"
name: "{{ prometheus_user }}"
home: "{{ prometheus_user_home }}"
group: "{{ prometheus_group }}"
groups: "{{ prometheus_extra_groups | join(',') }}"
- name: Install dependencies
package:
name: "{{ item }}"
state: present
loop:
- "{{ prometheus_packages }}"
- name: Setup local facts
file:
path: /etc/ansible/facts.d
state: directory
mode: 0755
become: True
become_user: root

View File

@ -1,130 +0,0 @@
---
- name: Prepare base folder
file:
path: "{{ prometheus_base_dir }}"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0750
become: True
become_user: root
- block:
- name: Prepare folder structure
file:
path: "{{ item }}"
state: directory
mode: 0750
loop:
- "{{ prometheus_config_dir }}"
- "{{ prometheus_rules_dir }}"
- "{{ prometheus_data_dir }}"
- "{{ prometheus_file_sd_dir }}"
- name: Download and extract Prometheus tarball
unarchive:
src: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz"
dest: "{{ prometheus_base_dir }}"
extra_opts:
- --strip-components=1
remote_src: yes
exclude:
- prometheus-{{ prometheus_version }}.linux-amd64/LICENSE
- prometheus-{{ prometheus_version }}.linux-amd64/NOTICE
- prometheus-{{ prometheus_version }}.linux-amd64/prometheus.yml
notify: __prometheus_restart
when: prometheus_version is version(prometheus_current_version, ">") or prometheus_current_version is version('0.0.0', "=")
become: True
become_user: "{{ prometheus_user }}"
- block:
- name: Copy prometheus config file
template:
src: "conf/prometheus.yml.j2"
dest: "{{ prometheus_config_dir }}/prometheus.yml"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0600
validate: "{{ prometheus_base_dir }}/promtool check config %s"
notify: __prometheus_reload
- name: Copy prometheus web config file
template:
src: "conf/web.yml.j2"
dest: "{{ prometheus_config_dir }}/web.yml"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0640
validate: "{{ prometheus_base_dir }}/promtool check web-config %s"
- name: Configure prometheus static targets
template:
src: "conf/file_sd/sd.yml.j2"
dest: "{{ prometheus_file_sd_dir }}/{{ item.name }}.yml"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0640
loop: "{{ prometheus_targets }}"
loop_control:
label: "{{ item.name }}"
- name: Copy prometheus custom static targets
copy:
src: "{{ item }}"
dest: "{{ prometheus_file_sd_dir }}"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0640
with_fileglob: "{{ prometheus_static_targets_files }}"
loop_control:
label: "{{ item | basename }}"
notify: __prometheus_reload
- name: Configure prometheus alerting rules
template:
src: "conf/rules/alert.rules.j2"
dest: "{{ prometheus_rules_dir }}/default.rules"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0640
validate: "{{ prometheus_base_dir }}/promtool check rules %s"
when: (prometheus_alert_rules + prometheus_alert_rules_extra) | length > 0
notify: __prometheus_reload
- name: Copy custom alerting rule files
copy:
src: "{{ item }}"
dest: "{{ prometheus_rules_dir }}/"
owner: "{{ prometheus_user }}"
group: "{{ prometheus_user }}"
mode: 0640
validate: "{{ prometheus_base_dir }}/promtool check rules %s"
with_fileglob: "{{ prometheus_alert_rules_files }}"
loop_control:
label: "{{ item | basename }}"
notify: __prometheus_reload
- name: Copy systemd unit file
template:
src: "etc/systemd/system/prometheus.service.j2"
dest: "/etc/systemd/system/prometheus.service"
mode: 0640
notify: __prometheus_restart
- name: Ensure prometheus service is up and running
service:
name: prometheus
daemon_reload: yes
enabled: yes
state: started
- name: Set current version to custom fact
template:
src: etc/ansible/facts.d/prometheus.fact.j2
dest: /etc/ansible/facts.d/prometheus.fact
mode: 0644
owner: root
group: root
when: prometheus_version is version(prometheus_current_version, ">") or prometheus_current_version is version('0.0.0', "=")
become: True
become_user: root

View File

@ -1,32 +0,0 @@
---
- block:
- name: Create tls folder structure
file:
path: "{{ item }}"
state: directory
owner: "{{ prometheus_user }}"
group: "{{ prometheus_group }}"
recurse: True
loop:
- "{{ prometheus_web_tls_cert_path | dirname }}"
- "{{ prometheus_web_tls_key_path | dirname }}"
become: True
become_user: root
- block:
- name: Copy certs and private key
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
- src: "{{ prometheus_web_tls_key_source }}"
dest: "{{ prometheus_web_tls_key_path }}"
mode: "0600"
- src: "{{ prometheus_web_tls_cert_source }}"
dest: "{{ prometheus_web_tls_cert_path }}"
mode: "0750"
loop_control:
label: "{{ item.dest }}"
become: True
become_user: "{{ prometheus_user }}"

View File

@ -1,4 +0,0 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
{{ item.config | to_nice_yaml(indent=2) }}

View File

@ -1,33 +0,0 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
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 | length > 0 %}
remote_write:
{{ prometheus_remote_write | to_nice_yaml(indent=2) | indent(2, False) }}
{% endif %}
{% if prometheus_remote_read | length > 0 %}
remote_read:
{{ prometheus_remote_read | to_nice_yaml(indent=2) | indent(2, False) }}
{% endif %}
rule_files:
- {{ prometheus_rules_dir }}/*.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) }}

View File

@ -1,7 +0,0 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
groups:
- name: Ansible managed alert rules
rules:
{{ (prometheus_alert_rules + prometheus_alert_rules_extra) | to_nice_yaml(indent=2) | indent(2, False) }}

View File

@ -1,26 +0,0 @@
#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
{% if prometheus_web_tls_enabled | bool %}
tls_server_config:
cert_file: {{ prometheus_web_tls_cert_path }}
key_file: {{ prometheus_web_tls_key_path }}
{% else %}
tls_server_config: {}
{% endif %}
{% if prometheus_web_http_server is defined %}
http_server_config:
{{ prometheus_web_http_server | to_nice_yaml(indent=2) | indent(2,False) }}
{% else %}
http_server_config: {}
{% endif %}
{% if prometheus_web_basic_auth_users is defined %}
basic_auth_users:
{{ prometheus_web_basic_auth_users | to_nice_yaml(indent=2) | indent(2,False) }}
{% else %}
basic_auth_users: {}
{% endif %}

View File

@ -1,4 +0,0 @@
{
"comment" : "{{ ansible_managed }}",
"version" : "{{ prometheus_version }}"
}

View File

@ -1,54 +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_user }}
Group={{ prometheus_group }}
WorkingDirectory={{ prometheus_base_dir }}
ExecReload=/bin/kill -HUP $MAINPID
ExecStart={{ prometheus_base_dir }}/prometheus \
--storage.tsdb.path={{ prometheus_data_dir }} \
--storage.tsdb.retention.time={{ prometheus_storage_retention }} \
--storage.tsdb.retention.size={{ prometheus_storage_retention_size }} \
--web.config.file={{ prometheus_config_dir }}/web.yml \
--web.console.libraries={{ prometheus_base_dir }}/console_libraries \
--web.console.templates={{ prometheus_base_dir }}/consoles \
--web.listen-address={{ prometheus_web_bind_ip }}:{{ prometheus_web_bind_port }} \
--web.external-url={{ prometheus_web_external_url }} \
{% for flag in prometheus_config_flags_extra %}
{% if flag.value is not defined %}
--{{ flag.name }} \
{% elif flag.value is string %}
--{{ flag.name }}={{ flag.value }} \
{% elif flag.value is sequence %}
{% for flag_value_item in flag.value %}
--{{ flag.name }}={{ flag_value_item }} \
{% endfor %}
{% endif %}
{% endfor %}
--log.level={{ prometheus_log_level }} \
--config.file={{ prometheus_config_dir }}/prometheus.yml
LimitNOFILE=65000
NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
ReadWriteDirectories={{ prometheus_data_dir }}
{% for path in prometheus_read_only_dirs %}
ReadOnlyDirectories={{ path }}
{% endfor %}
ProtectSystem=full
SyslogIdentifier=prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target