From 24b74c84278835dba0faa689be75fe8677b0e9d3 Mon Sep 17 00:00:00 2001 From: Waldek Maleska Date: Fri, 22 Mar 2024 11:07:34 +0000 Subject: [PATCH] pushgateway extra parameters Allow passing in additional parameters for the pushgateway binary * pushgateway_web_external_url - useful when running behind a reverse proxy * pushgateway_cli_extra_flags - additional extra flags for flexibility Signed-off-by: Waldek Maleska --- roles/pushgateway/defaults/main.yml | 8 ++++++++ roles/pushgateway/templates/pushgateway.service.j2 | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/roles/pushgateway/defaults/main.yml b/roles/pushgateway/defaults/main.yml index 201fd9fa1..6668da85f 100644 --- a/roles/pushgateway/defaults/main.yml +++ b/roles/pushgateway/defaults/main.yml @@ -9,6 +9,14 @@ pushgateway_skip_install: false pushgateway_web_listen_address: "0.0.0.0:9091" pushgateway_web_telemetry_path: "/metrics" +# External address on which pushgateway is available. +# Useful when behind reverse proxy, e.g.: https://example.org/pushgateway +pushgateway_web_external_url: "" + +# Optional extra flags to be passed to pushgateway binary, e.g. +# ['--log.level=debug', '--log.format=json'] +pushgateway_cli_extra_flags: [] + pushgateway_tls_server_config: {} pushgateway_http_server_config: {} diff --git a/roles/pushgateway/templates/pushgateway.service.j2 b/roles/pushgateway/templates/pushgateway.service.j2 index eeab97e41..2f29ab9c8 100644 --- a/roles/pushgateway/templates/pushgateway.service.j2 +++ b/roles/pushgateway/templates/pushgateway.service.j2 @@ -25,6 +25,17 @@ ExecStart={{ pushgateway_binary_install_dir }}/pushgateway \ {% endfor %} {% else %} '--web.listen-address={{ pushgateway_web_listen_address }}' \ +{% endif %} +{% if pushgateway_web_external_url %} + '--web.external-url={{ pushgateway_web_external_url }}' \ +{% endif %} +{% if pushgateway_cli_extra_flags and + pushgateway_cli_extra_flags is iterable and + pushgateway_cli_extra_flags is not mapping and + pushgateway_cli_extra_flags is not string %} +{% for extra_flag in pushgateway_cli_extra_flags %} + '{{ extra_flag }}' \ +{% endfor %} {% endif %} '--web.telemetry-path={{ pushgateway_web_telemetry_path }}'