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.4 KiB

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