From 772df61f5a46a30f48266df805014a8978503faa Mon Sep 17 00:00:00 2001 From: sfhl <59044937+sfhl@users.noreply.github.com> Date: Mon, 8 Apr 2024 05:22:53 +0200 Subject: [PATCH] feat: add promtail_extra_args variable to allow configuring the service arguments (#207) add promtail_extra_args --- README.md | 1 + defaults/main.yml | 2 ++ templates/service.j2 | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f56ab9b..3dcce4d 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ All variables which can be overridden are stored in [defaults/main.yml](defaults | `promtail_version` | "2.9.4" | promtail package version. Also accepts *latest* as parameter. | | `promtail_custom_checksum` | "" | Custom checksum for custom build promtail binaries | | `promtail_binary_local_dir` | "" | Allows to use local packages instead of ones distributed on github. As parameter it takes the path where zip archive of promtail is stored on host on which ansible is ran. | +| `promtail_extra_args` | [] | Allows to set extra arguments to the binary within the systemd service file. | | `promtail_config_dir` | /etc/promtail | Directory for storing promtail configuration file | | `promtail_config_expand_env` | "false" | value of promtail [-config.expand-env](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#use-environment-variables-in-the-configuration) option | | `promtail_config_file_sd_dir` | "{{ promtail_config_dir }}/file_sd" | Default directory for `file_sd` discovery | diff --git a/defaults/main.yml b/defaults/main.yml index 33bf041..36d4c58 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,8 @@ promtail_user_additional_groups: "adm" promtail_systemd_service_template_file: service.j2 promtail_systemd_service: promtail +promtail_extra_args: [] + promtail_binary_local_dir: "" promtail_binary_propagate: False diff --git a/templates/service.j2 b/templates/service.j2 index 41ac443..8252e06 100644 --- a/templates/service.j2 +++ b/templates/service.j2 @@ -11,7 +11,7 @@ RestartSec=5 TimeoutSec=5 User={{ promtail_system_user }} Group={{ promtail_system_group }} -ExecStart=/usr/local/bin/promtail -config.file={{ promtail_config_file }} -log.level={{ promtail_log_level }} -config.expand-env={{ promtail_config_expand_env | lower }} +ExecStart=/usr/local/bin/promtail -config.file={{ promtail_config_file }} -log.level={{ promtail_log_level }} -config.expand-env={{ promtail_config_expand_env | lower }} {{ promtail_extra_args | join(' ') }} [Install] WantedBy=multi-user.target