Skip to content

Commit

Permalink
promtail: add support for extra args (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
voidquark authored Aug 16, 2024
2 parents c775eb8 + 2f29525 commit bf3fdf3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions roles/promtail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ By default, Promtail runs in root-less mode. It supports two modes:
- `acl`: Root-less mode, utilizing ACL permission model to read target log files.
- `root`: Root mode, where Promtail runs as root and ACL configuration is skipped.

```yaml
promtail_extra_flags: []
```
Additional flags to be passed to the Promtail systemd unit.

```yaml
promtail_user_append_groups:
- "systemd-journal"
Expand Down
4 changes: 4 additions & 0 deletions roles/promtail/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ promtail_http_listen_address: "0.0.0.0"
promtail_expose_port: false
promtail_positions_path: "/var/lib/promtail"
promtail_runtime_mode: "acl" # Supported "root" or "acl"
promtail_extra_flags: []
# promtail_extra_flags:
# - "-server.enable-runtime-reload"
# - "-config.expand-env=true"

promtail_user_append_groups:
- "systemd-journal"
Expand Down
2 changes: 1 addition & 1 deletion roles/promtail/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
owner: "promtail"
group: "root"
mode: "0644"
validate: "/usr/bin/promtail -check-syntax -config.file %s"
validate: "/usr/bin/promtail -config.expand-env=true -check-syntax -config.file %s"
notify: restart promtail

- name: Template Promtail systemd - /etc/systemd/system/promtail.service
Expand Down
8 changes: 7 additions & 1 deletion roles/promtail/templates/promtail.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ User=promtail
{% elif promtail_runtime_mode == "root" %}
User=root
{% endif %}
ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml
ExecStart=/usr/bin/promtail \
{% if promtail_extra_flags | length > 0 %}
{% for flag in promtail_extra_flags %}
{{ flag }} \
{% endfor %}
{% endif %}
-config.file /etc/promtail/config.yml

TimeoutSec = 60
Restart = on-failure
Expand Down

0 comments on commit bf3fdf3

Please sign in to comment.