Skip to content

digitalis-io/ansible-playbook-monitoring

Repository files navigation

Prometheus Monitoring Stack Deployment

This repository provides an Ansible playbook to deploy a comprehensive Prometheus monitoring stack, including Prometheus, Alertmanager, Grafana, Loki, and Mimir, with optional SSL and Nginx reverse proxy configuration.

Overview

The deploy-prometheus.yml playbook automates the installation and configuration of a full monitoring stack on your infrastructure. It handles package installation, service configuration, SSL setup (custom or self-signed), and Nginx reverse proxying for secure access.

Features

  • Installs and configures:
    • Prometheus (metrics collection)
    • Alertmanager (alerting)
    • Grafana (visualization)
    • Loki (log aggregation)
    • Mimir (long-term metrics storage)
  • Handles SSL certificate setup (custom or self-signed)
  • Configures Nginx as a reverse proxy
  • Installs required system packages
  • Cleans up default Nginx configuration
  • Supports handler tasks for service reloads

Prerequisites

  • Ansible 2.9+ installed on your control machine
  • SSH access to target hosts (inventory group: prometheus) with appropriate privileges
  • The following Ansible Galaxy roles installed:
    • prometheus.prometheus
    • grafana.grafana
  • (Optional) SSL certificate variables defined in your inventory or group_vars

Usage

  1. Install required roles:

    ansible-galaxy install -r requirements.yml
  2. Prepare your inventory:

    Edit inventory/test or your own inventory file to define the prometheus group and hosts.

  3. Configure variables:

    • Edit files in group_vars/all/ to set up Alertmanager, Grafana, Loki, Nginx, Prometheus, etc.
    • To use custom SSL certificates, define ssl_certs in your variables.
    • If ssl_certs is not defined, self-signed certificates will be generated.
  4. Run the playbook:

    ansible-playbook -i inventory/test deploy-prometheus.yml

    Add --tags to limit execution to specific components (e.g., --tags grafana).

Playbook Structure

  • Handlers: Reload/restart systemd services and update CA certificates as needed.
  • Pre-tasks: Install system packages, remove unnecessary packages, set up SSL, and clean up default Nginx config.
  • Roles: Deploy Prometheus, Alertmanager, Loki, Grafana, and Mimir using community roles.
  • Post-tasks: Import and apply custom Nginx configuration.

Customization

  • SSL:
    • To use your own certificates, define ssl_certs in your variables.
    • If not defined, self-signed certificates will be created for Nginx.
  • Nginx:
    • Custom configuration is managed via the _nginx.yml task file and related templates.

Troubleshooting

  • Ensure all required roles are installed before running the playbook.
  • If running from macOS, see this issue for compatibility notes.
  • Review linter warnings for best practices, but the playbook should function as written.

About Us

At Digitalis, our mission is to make the adoption of cloud-native and distributed data technologies as easy and seamless as possible for enterprises—on any Kubernetes, any cloud, and any data center. We focus on the technology stack that powers modern businesses, knowing this area can create a significant impact for our customers. If your organization is considering these technologies to drive transformation, we're here to guide you every step of the way.

Contact our team for a free consultation to discuss how we can tailor our approach to your specific needs and challenges.

License

Apache License 2.0. See LICENSE for details.

About

This repository contains a sample playbook to install a full monitoring stack based on Grafana and Prometheus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published