add alertmanager role
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
global:
|
||||
# SMTP configuration for email notifications (if needed)
|
||||
smtp_smarthost: 'mailserver.example.com:587'
|
||||
smtp_from: 'alertmanager@example.com'
|
||||
smtp_auth_username: 'alertmanager'
|
||||
smtp_auth_password: 'your_password'
|
||||
|
||||
# Other global settings like resolve_timeout, http_config, etc.
|
||||
|
||||
route:
|
||||
# Default receiver for alerts
|
||||
receiver: 'default-receiver'
|
||||
|
||||
# Labels used for grouping alerts
|
||||
group_by: ['alertname', 'instance', 'severity']
|
||||
|
||||
# Timing settings (group_wait, group_interval, repeat_interval)
|
||||
# You can have nested 'routes' for more complex routing logic
|
||||
|
||||
receivers:
|
||||
- name: 'default-receiver'
|
||||
email_configs:
|
||||
- to: 'ops-team@example.com'
|
||||
|
||||
inhibit_rules:
|
||||
# Rules to suppress alerts based on other alerts
|
||||
# Example:
|
||||
- source_match:
|
||||
severity: 'critical'
|
||||
target_match:
|
||||
severity: 'warning'
|
||||
# Suppress 'warning' alerts if a 'critical' alert is also firing
|
||||
|
||||
templates:
|
||||
# Paths to template files for customizing notifications
|
||||
- '/etc/alertmanager/templates/*.tmpl'
|
||||
6
roles/alertmanager/molecule/default/converge.yml
Normal file
6
roles/alertmanager/molecule/default/converge.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: genlab.alertmanager
|
||||
config_source_dir: alertmanager
|
||||
27
roles/alertmanager/molecule/default/molecule.yml
Normal file
27
roles/alertmanager/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
platforms:
|
||||
- name: ubuntu
|
||||
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2404}-ansible:latest
|
||||
pre_build_image: true
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
|
||||
verifier:
|
||||
name: ansible
|
||||
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
ansible-lint .
|
||||
55
roles/alertmanager/molecule/default/verify.yml
Normal file
55
roles/alertmanager/molecule/default/verify.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
|
||||
- name: "Include default vars"
|
||||
ansible.builtin.include_vars:
|
||||
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
|
||||
extensions: [ 'yml' ]
|
||||
|
||||
- name: "Check if Alertmanager is installed"
|
||||
changed_when: false
|
||||
ansible.builtin.command: "alertmanager --version"
|
||||
register: alertmanager_installed_version
|
||||
|
||||
- name: "Check Alertmanager version"
|
||||
ansible.builtin.assert:
|
||||
that: "alertmanager_installed_version.stdout is regex('{{ alertmanager_version }}')"
|
||||
success_msg: "Alertmanager version {{ alertmanager_version }} is installed and working"
|
||||
fail_msg: "Alertmanager version {{ alertmanager_version }} is not installed or not working correctly"
|
||||
|
||||
# kics-scan ignore-block
|
||||
- name: "Check if Alertmanager is reachable"
|
||||
ansible.builtin.uri:
|
||||
url: "http://localhost:9093/-/healthy"
|
||||
return_content: true
|
||||
status_code: 200
|
||||
method: GET
|
||||
body_format: json
|
||||
register: alertmanager_health
|
||||
|
||||
- name: "Assert Alertmanager health status"
|
||||
ansible.builtin.assert:
|
||||
that: "alertmanager_health.content == 'OK'"
|
||||
success_msg: "Alertmanager is healthy"
|
||||
fail_msg: "Alertmanager is not healthy"
|
||||
|
||||
# kics-scan ignore-block
|
||||
- name: "Check if Alertmanager is ready"
|
||||
ansible.builtin.uri:
|
||||
url: "http://localhost:9093/-/ready"
|
||||
return_content: true
|
||||
status_code: 200
|
||||
method: GET
|
||||
body_format: json
|
||||
register: alertmanager_ready
|
||||
|
||||
- name: "Assert Alertmanager readiness status"
|
||||
ansible.builtin.assert:
|
||||
that: "alertmanager_ready.content == 'OK'"
|
||||
success_msg: "Alertmanager is ready"
|
||||
fail_msg: "Alertmanager is not ready"
|
||||
Reference in New Issue
Block a user