Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
2.1 KiB

  1. ---
  2. - set_fact:
  3. matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-prometheus-node-exporter.service'] }}"
  4. when: matrix_prometheus_node_exporter_enabled|bool
  5. - block:
  6. - name: Fail if matrix-nginx-proxy role already executed
  7. fail:
  8. msg: >-
  9. Trying to append node-exporter's reverse-proxying configuration to matrix-nginx-proxy,
  10. but it's pointless since the matrix-nginx-proxy role had already executed.
  11. To fix this, please change the order of roles in your playbook,
  12. so that the matrix-nginx-proxy role would run after the matrix-prometheus-node-exporter role.
  13. when: matrix_nginx_proxy_role_executed|default(False)|bool
  14. - name: Generate node-exporter metrics proxying configuration for matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter)
  15. set_fact:
  16. matrix_prometheus_node_exporter_nginx_metrics_configuration_block: |
  17. location /metrics/node-exporter {
  18. {% if matrix_nginx_proxy_enabled|default(False) %}
  19. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  20. resolver 127.0.0.11 valid=5s;
  21. set $backend "matrix-prometheus-node-exporter:9100";
  22. proxy_pass http://$backend/metrics;
  23. {% else %}
  24. {# Generic configuration for use outside of our container setup #}
  25. {# This may be implemented in the future. #}
  26. return 404 "matrix-nginx-proxy is disabled, so metrics are unavailable";
  27. {% endif %}
  28. }
  29. - name: Register node-exporter metrics proxying configuration with matrix-nginx-proxy (matrix.DOMAIN/metrics/node-exporter)
  30. set_fact:
  31. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks: |
  32. {{
  33. matrix_nginx_proxy_proxy_matrix_metrics_additional_system_location_configuration_blocks|default([])
  34. +
  35. [matrix_prometheus_node_exporter_nginx_metrics_configuration_block]
  36. }}
  37. when: matrix_prometheus_node_exporter_enabled|bool and matrix_prometheus_node_exporter_metrics_proxying_enabled|bool