|
1 | | -<!-- |
2 | | - Copyright 2024 Cloudera, Inc. |
| 1 | +# prometheus |
3 | 2 |
|
4 | | - Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | - you may not use this file except in compliance with the License. |
6 | | - You may obtain a copy of the License at |
| 3 | +Install Prometheus. |
7 | 4 |
|
8 | | - https://www.apache.org/licenses/LICENSE-2.0 |
| 5 | +This role automates the installation of the Prometheus monitoring system from its official distribution archive. It sets up the necessary directories for configuration and the time-series database (TSDB), creates a dedicated system user and group for the service, and installs a basic Prometheus configuration to get started. |
9 | 6 |
|
10 | | - Unless required by applicable law or agreed to in writing, software |
11 | | - distributed under the License is distributed on an "AS IS" BASIS, |
12 | | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | - See the License for the specific language governing permissions and |
14 | | - limitations under the License. |
15 | | ---> |
| 7 | +The role will: |
| 8 | +- Create a dedicated system user and group (`prometheus`). |
| 9 | +- Create necessary directories for Prometheus configuration (`/etc/prometheus`) and TSDB storage (`/var/lib/prometheus`). |
| 10 | +- Download the Prometheus distribution tarball. |
| 11 | +- Extract the Prometheus binary and related files to the installation directory. |
| 12 | +- Install a basic `prometheus.yml` configuration file. |
| 13 | +- Set up a `systemd` service for Prometheus. |
| 14 | +- Enable and start the Prometheus service, ensuring it runs on system boot. |
16 | 15 |
|
17 | | -# prometheus |
| 16 | +# Requirements |
| 17 | + |
| 18 | +- Target host must have `systemd` for service management. |
| 19 | +- Internet access on the target host to download the Prometheus tarball. |
| 20 | + |
| 21 | +# Dependencies |
| 22 | + |
| 23 | +None. |
| 24 | + |
| 25 | +# Parameters |
| 26 | + |
| 27 | +| Variable | Type | Required | Default | Description | |
| 28 | +| --- | --- | --- | --- | --- | |
| 29 | +| `prometheus_tarball_url` | `str` | `False` | `https://github.com/prometheus/prometheus/releases/download/v2.48.1/prometheus-2.48.1.linux-amd64.tar.gz` | URL to the Prometheus distribution archive file. | |
| 30 | +| `prometheus_directory` | `path` | `False` | `/etc/prometheus` | Prometheus configuration directory. | |
| 31 | +| `prometheus_tsdb_directory` | `path` | `False` | `/var/lib/prometheus` | Prometheus TSDB directory. | |
| 32 | +| `prometheus_tarball_file` | `str` | `False` | `prometheus.tar.gz` | Intermediate archive file name for the downloaded tarball. | |
| 33 | +| `prometheus_user` | `str` | `False` | `prometheus` | Prometheus service user. | |
| 34 | +| `prometheus_group` | `str` | `False` | `prometheus` | Prometheus service group. | |
| 35 | +| `prometheus_service_directory` | `path` | `False` | `/etc/systemd/system/prometheus.service` | Prometheus Systemd service directory (full path to the service file). | |
| 36 | + |
| 37 | +# Example Playbook |
| 38 | + |
| 39 | +```yaml |
| 40 | +- hosts: monitoring_servers |
| 41 | + tasks: |
| 42 | + - name: Install Prometheus server with custom settings |
| 43 | + ansible.builtin.import_role: |
| 44 | + name: prometheus |
| 45 | + vars: |
| 46 | + prometheus_tarball_url: "[https://github.com/prometheus/prometheus/releases/download/v2.49.0/prometheus-2.49.0.linux-amd64.tar.gz](https://github.com/prometheus/prometheus/releases/download/v2.49.0/prometheus-2.49.0.linux-amd64.tar.gz)" |
| 47 | + prometheus_directory: "/opt/prometheus/config" |
| 48 | + prometheus_tsdb_directory: "/data/prometheus_tsdb" |
| 49 | + prometheus_user: "prom_admin" |
| 50 | + prometheus_group: "prom_admin" |
| 51 | +``` |
| 52 | +
|
| 53 | +# License |
| 54 | +
|
| 55 | +``` |
| 56 | +Copyright 2025 Cloudera, Inc. |
| 57 | + |
| 58 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 59 | +you may not use this file except in compliance with the License. |
| 60 | +You may obtain a copy of the License at |
| 61 | + |
| 62 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 63 | + |
| 64 | +Unless required by applicable law or agreed to in writing, software |
| 65 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 66 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 67 | +See the License for the specific language governing permissions and |
| 68 | +limitations under the License. |
| 69 | +``` |
0 commit comments