kolla-ansible/ansible/roles/prometheus/tasks/precheck.yml
Jorge Niedbalski 1596475db6 [prometheus] Initial implementation of prometheus-alertmanager
This patch extends the prometheus role for being able
to deploy the prometheus-alertmanager[0] container.

The variable enable_prometheus_alertmanager
decides if the container should be deployed and enabled.

If enabled, the following configuration and actions are performed:

- The alerting section on the prometheus-server configuration
is added pointing the prometheus-alertmanager host group as targets.

- HAProxy is configured to load-balance over the prometheus-alertmanager
host group. (external/internal).

Please note that a default (dummy) configuration is provided, that
allows the service to start, the operator should extend it via a node custom config

[0] https://github.com/openstack/kolla/tree/master/docker/prometheus/prometheus-alertmanager

Change-Id: I3a13342c67744a278cc8d52900a913c3ccc452ae
Closes-Bug: 1774725
Signed-off-by: Jorge Niedbalski <jorge.niedbalski@linaro.org>
2018-07-11 16:20:35 -04:00

98 lines
3.4 KiB
YAML

---
- name: Get container facts
kolla_container_facts:
name:
- prometheus_server
- prometheus_node_exporter
- prometheus_haproxy_exporter
- prometheus_mysqld_exporter
- prometheus_cadvisor
- prometheus_alertmanager
register: container_facts
- name: Checking free port for Prometheus server
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_server'] is not defined
- inventory_hostname in groups['prometheus']
- name: Checking free port for Prometheus node_exporter
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_node_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_node_exporter'] is not defined
- inventory_hostname in groups['prometheus-node-exporter']
- enable_prometheus_node_exporter | bool
- name: Checking free port for Prometheus mysqld_exporter
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_mysqld_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_mysqld_exporter'] is not defined
- inventory_hostname in groups['prometheus-mysqld-exporter']
- enable_prometheus_mysqld_exporter | bool
- name: Checking free port for Prometheus haproxy_exporter
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_haproxy_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_mysqld_exporter'] is not defined
- inventory_hostname in groups['prometheus-haproxy-exporter']
- enable_prometheus_haproxy_exporter | bool
- name: Checking free port for Prometheus memcached_exporter
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_memcached_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_memcached_exporter'] is not defined
- inventory_hostname in groups['prometheus-memcached-exporter']
- enable_prometheus_memcached_exporter | bool
- name: Checking free port for Prometheus cAdvisor
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ prometheus_cadvisor_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_cadvisor'] is not defined
- inventory_hostname in groups['prometheus-cadvisor']
- enable_prometheus_cadvisor | bool
- name: Checking free ports for Prometheus Alertmanager
wait_for:
host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
port: "{{ item }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_alertmanager'] is not defined
- inventory_hostname in groups['prometheus-alertmanager']
- enable_prometheus_alertmanager | bool
with_items:
- "{{ prometheus_alertmanager_port }}"
- "{{ prometheus_alertmanager_cluster_port }}"