Deploy promtail using ansible. Supports amd64 and arm architectures. For recent changes, please check the CHANGELOG or have a look at github releases
- Ansible >= 2.7
All variables which can be overridden are stored in defaults/main.yml file as well as in table below.
ToDo
For each section (promtail_config_clients
, promtail_config_server
,promtail_config_positions
,promtail_config_scrape_configs
,promtail_target_config
) the configuration can be passed accrodingly to the official promtail configuration.
The role will converte the ansible vars into the respective yaml configuration for loki.
Basic playbook that will assume that loki will be listening at http://127.0.0.1:3100
and a simple configuration to scrape /var/log
logs:
---
- hosts: all
roles:
- role: patrickjahns.promtail
vars:
promtail_config_scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log
A more complex example, that overrides server, client, positions configuration and provides a scrap configuration for /var/log
:
---
- hosts: all
roles:
- role: patrickjahns.promtail
vars:
promtail_config_server:
http_listen_port: 9080
grpc_listen_port: 9081
promtail_config_clients:
- url: "http://prometheus.domain.tld:3100/loki/api/v1/push"
external_labels:
host: "{{ ansible_hostname }}"
promtail_config_positions:
filename: "{{ promtail_positions_directory }}/positions.yaml"
sync_period: "60s"
promtail_config_scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*log
The preferred way of locally testing the role is to use Docker and molecule (v3.x). You will have to install Docker on your system. See "Get started" for a Docker package suitable to for your system. We are using tox to simplify process of testing on multiple ansible versions. To install tox execute:
pip3 install tox
To run tests on all ansible versions (WARNING: this can take some time)
tox
To run a custom molecule command on custom environment with only default test scenario:
tox -e ansible29 -- molecule test -s default
For more information about molecule go to their docs.
If you would like to run tests on remote docker host just specify DOCKER_HOST
variable before running tox tests.
Github actions is used to test and validate this ansible role via ansible-later and molecule. Molecule tests will run with several operation systems as well as ansible version in order to ensure compatability.
This project is licensed under MIT License. See LICENSE for more details.
This role is based on the ansible promtail role done by Patrick Jahns.
Alex Barcelo forked that and modified it in order to achieve a loki and promtail installation role.