Installs Prometheus on Ubuntu 16.04 (Xenial)
This role requires Ansible 2.4 or higher.
The role defines most of its variables in defaults/main.yml
:
- List of components to be installed.
- Default value: ["prometheus", "alertmanager", "telegram_bot"]
Telegram bot will install docker
-
Url of the Alertmanager service.
-
Default value: http://{{alertmanager_url}}:{{alertmanager_port}}
-
Result Value "http://localhost:9093/"
- Default Value: localhost
- Default : 9093
- Version of the Prometheus service.
- Default value: 2.4.2
- Version of the Alertmanager service.
- Default value: 0.15.2
- The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.
- Default value: Not defined (By default get hostname)
- Prefix forthe internal routes of web endpoints.
- Default value: Void
- The URL under which Alertmanager is externally reachable (for example, if Alertmanagr is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically.
- Default value: Not defined (By default get hostname)
- Prefix forthe internal routes of web endpoints.
- Default value: Void
Run with default vars:
- hosts: all
roles:
- role: ansible-prometheus
prometheus_server: prometheus_hostname
Run with default vars:
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_rule_files:
basic_rules:
src: "prometheus/rules/basic.rules"
dest: basic.rules
black_box_rules:
src: "prometheus/rules/black_box.rules"
dest: black_box.rules
├── group_vars
│ └── all
├── host
├── playbook.yml
├── prometheus
│ ├── alertmanager.yml
│ ├── prometheus.yml
│ ├── rules
│ │ ├── basic.rules
│ │ └── black_box.rules
│ └── telegram_bot
│ ├── config.yaml
│ └── template.tmpl
├── requirements.yaml
└── roles
Run with default vars:
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_prometheus_bot_template_conf: prometheus/telegram_bot/template.tmpl
prometheus_prometheus_bot_conf: prometheus/telegram_bot/config.yaml
prometheus_rule_files:
basic_rules:
src: "prometheus/rules/basic.rules"
dest: basic.rules
black_box_rules:
src: "prometheus/rules/black_box.rules"
dest: black_box.rules
you can manage rules by git repository, in 4 ways.
In case you wanna clone rules from openrepository. Example: https://github.com/entercloudsuite/prometheus-rules-collections.git
you nead configure just var prometheus_rule_git_repo
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_rule_git_repo: https://github.com/entercloudsuite/prometheus-rules-collections.git
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_rule_git_repo: [email protected]:myuser/my_repo.git
prometheus_rule_git_key_pathfile: /path_to_key/inmyserver/private.pem
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_rule_git_repo: [email protected]:myuser/my_repo.git
prometheus_rule_git_key: |
-----BEGIN OPENSSH PRIVATE KEY-----
MY_KEY
-----END OPENSSH PRIVATE KEY-----
- hosts: all
roles:
- role: entercloudsuite.prometheus
prometheus_conf_main: "prometheus/prometheus.yml"
prometheus_alertmanager_conf: "prometheus/alertmanager.yml"
prometheus_rule_git_repo: https://git_username:[email protected]/myuser/my_repo.git
Tests are performed using Molecule.
Install Molecule or use docker-compose run --rm molecule
to run a local Docker container, based on the enterclousuite/molecule project, from where you can use molecule
.
- Run
molecule create
to start the target Docker container on your local engine. - Use
molecule login
to log in to the running container. - Edit the role files.
- Add other required roles (external) in the molecule/default/requirements.yml file.
- Edit the molecule/default/playbook.yml.
- Define infra tests under the molecule/default/tests folder using the goos verifier.
- When ready, use
molecule converge
to run the Ansible Playbook andmolecule verify
to execute the test suite.
Note that the converge process starts performing a syntax check of the role.
Destroy the Docker container with the commandmolecule destroy
.
To run all the steps with just one command, run molecule test
.
In order to run the role targeting a VM, use the playbook_deploy.yml file for example with the following command: ansible-playbook ansible-prometheus/molecule/default/playbook_deploy.yml -i VM_IP_OR_FQDN, -u ubuntu --private-key private.pem
.
docker-compose run --rm molecule molecule create molecule converge
MIT