2022-02-05 20:32:54 +00:00
|
|
|
---
|
|
|
|
|
2022-09-27 08:38:33 +00:00
|
|
|
- when: matrix_prometheus_node_exporter_enabled | bool and matrix_prometheus_node_exporter_metrics_proxying_enabled | bool
|
|
|
|
block:
|
2022-06-23 14:44:11 +00:00
|
|
|
- name: Fail if matrix-nginx-proxy role already executed
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.fail:
|
2022-06-23 14:44:11 +00:00
|
|
|
msg: >-
|
|
|
|
Trying to append node-exporter's reverse-proxying configuration to matrix-nginx-proxy,
|
|
|
|
but it's pointless since the matrix-nginx-proxy role had already executed.
|
|
|
|
To fix this, please change the order of roles in your playbook,
|
|
|
|
so that the matrix-nginx-proxy role would run after the matrix-prometheus-node-exporter role.
|
2022-07-18 08:22:05 +00:00
|
|
|
when: matrix_nginx_proxy_role_executed | default(False) | bool
|
2022-06-23 14:44:11 +00:00
|
|
|
|
|
|
|
- name: Generate node-exporter metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2022-06-23 14:44:11 +00:00
|
|
|
matrix_prometheus_node_exporter_nginx_metrics_configuration_block: |
|
|
|
|
location /metrics/node-exporter {
|
2022-07-18 08:22:05 +00:00
|
|
|
{% if matrix_nginx_proxy_enabled | default(False) %}
|
2022-06-23 14:44:11 +00:00
|
|
|
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
|
|
|
resolver 127.0.0.11 valid=5s;
|
|
|
|
set $backend "matrix-prometheus-node-exporter:9100";
|
|
|
|
proxy_pass http://$backend/metrics;
|
2022-07-28 13:11:42 +00:00
|
|
|
{% elif matrix_prometheus_node_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host != '' %}
|
|
|
|
proxy_pass http://{{ matrix_prometheus_node_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host }}/metrics;
|
2022-06-23 14:44:11 +00:00
|
|
|
{% else %}
|
2022-07-28 13:11:42 +00:00
|
|
|
return 404 "matrix-nginx-proxy is disabled and no host port was bound to the container, so metrics are unavailable";
|
2022-06-23 14:44:11 +00:00
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
|
|
|
|
- name: Register node-exporter metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2022-06-23 14:44:11 +00:00
|
|
|
matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: |
|
|
|
|
{{
|
2022-07-18 08:22:05 +00:00
|
|
|
matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks | default([])
|
2022-06-23 14:44:11 +00:00
|
|
|
+
|
|
|
|
[matrix_prometheus_node_exporter_nginx_metrics_configuration_block]
|
|
|
|
}}
|