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.
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.
- 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
- 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
-
Install required roles:
ansible-galaxy install -r requirements.yml
-
Prepare your inventory:
Edit
inventory/test
or your own inventory file to define theprometheus
group and hosts. -
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.
- Edit files in
-
Run the playbook:
ansible-playbook -i inventory/test deploy-prometheus.yml
Add
--tags
to limit execution to specific components (e.g.,--tags grafana
).
- 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.
- SSL:
- To use your own certificates, define
ssl_certs
in your variables. - If not defined, self-signed certificates will be created for Nginx.
- To use your own certificates, define
- Nginx:
- Custom configuration is managed via the
_nginx.yml
task file and related templates.
- Custom configuration is managed via the
- 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.
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.
Apache License 2.0. See LICENSE for details.