{"id":13585675,"url":"https://github.com/patrickjahns/ansible-role-promtail","last_synced_at":"2025-04-04T15:08:00.681Z","repository":{"id":36994930,"uuid":"239170234","full_name":"patrickjahns/ansible-role-promtail","owner":"patrickjahns","description":"🔧 Ansible role for deploying promtail","archived":false,"fork":false,"pushed_at":"2025-03-11T17:01:01.000Z","size":275,"stargazers_count":105,"open_issues_count":16,"forks_count":58,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T09:09:39.656Z","etag":null,"topics":["ansible","ansible-role","logging","loki","promtail","role"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrickjahns.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-08T17:06:42.000Z","updated_at":"2025-03-07T08:54:20.000Z","dependencies_parsed_at":"2023-02-17T10:15:24.097Z","dependency_job_id":"8e322d33-0ee0-48cb-aacd-5bc1e07778e8","html_url":"https://github.com/patrickjahns/ansible-role-promtail","commit_stats":{"total_commits":214,"total_committers":27,"mean_commits":7.925925925925926,"dds":0.6355140186915889,"last_synced_commit":"6c3c60cd587ac47fa5881b27f985297f3770b6b5"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickjahns%2Fansible-role-promtail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickjahns%2Fansible-role-promtail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickjahns%2Fansible-role-promtail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickjahns%2Fansible-role-promtail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickjahns","download_url":"https://codeload.github.com/patrickjahns/ansible-role-promtail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198458,"owners_count":20900080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","logging","loki","promtail","role"],"created_at":"2024-08-01T15:05:04.742Z","updated_at":"2025-04-04T15:08:00.662Z","avatar_url":"https://github.com/patrickjahns.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Ansible Role: promtail\n\n[![Test](https://github.com/patrickjahns/ansible-role-promtail/workflows/Test/badge.svg)](https://github.com/patrickjahns/ansible-role-promtail/actions?query=workflow%3ATest+branch%3Amaster)\n[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)\n[![Ansible Role](https://img.shields.io/badge/ansible%20role-patrickjahns.promtail-blue.svg)](https://galaxy.ansible.com/patrickjahns/promtail/)\n[![GitHub tag](https://img.shields.io/github/tag/patrickjahns/ansible-role-promtail.svg)](https://github.com/patrickjahns/ansible-role-promtail/tags)\n\n## Description\n\nDeploy [promtail](https://github.com/grafana/loki) using ansible. Supports amd64 and arm architectures.\nFor recent changes, please check the [CHANGELOG](/CHANGELOG.md) or have a look at [github releases](https://github.com/patrickjahns/ansible-role-promtail/releases)\n\n\n## Requirements\n\n- Ansible \u003e= 2.7\n\n## Role Variables\n\nAll variables which can be overridden are stored in [defaults/main.yml](defaults/main.yml) file as well as in table below.\n\n| Name                                             | Default Value                                                    | Description                                                                                                            |\n|--------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| `promtail_version`                               | \"3.0.0\"                                                          | promtail package version. Also accepts *latest* as parameter.                                                          |\n| `promtail_custom_checksum`                       | \"\"                                                               | Custom checksum for custom build promtail binaries                                                                     |\n| `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. |\n| `promtail_extra_args`                            | []                                                               | Allows to set extra arguments to the binary within the systemd service file. |\n| `promtail_config_dir`                            | /etc/promtail                                                    | Directory for storing promtail configuration file                                                                      |\n| `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 |\n| `promtail_config_file_sd_dir`                    | \"{{ promtail_config_dir }}/file_sd\"                              | Default directory for `file_sd` discovery                                                                              |\n| `promtail_config_file`                           | \"{{ promtail_config_dir }}/promtail.yml\"                         | Configuration file used by promtail                                                                                    |\n| `promtail_system_user`                           | promtail                                                         | User the promtail process will run at                                                                                  |\n| `promtail_system_group`                          | \"{{ promtail_system_user }}\"                                     | Group of the *promtail* user                                                                                           |\n| `promtail_user_additional_groups`                | \"adm\"                                                            | Additional groups to be added to *promtail* user to give access to allow scraping of specific log files                |\n| `promtail_config_clients`                        | see [defaults/main.yml](defaults/main.yml)                       | promtail [clients](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#clientsg) section              |\n| `promtail_loki_server_url`                       | http://127.0.0.1:3100                                            | Server url where promtail will push its result                                                                         |\n| `promtail_config_server`                         | see [defaults/main.yml](defaults/main.yml)                       | promtail [server](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#server) section                 |\n| `promtail_positions_directory`                   | `/var/lib/promtail`                                              | Path to the directory where promtail tracks scraped log positons                                                       |\n| `promtail_config_positions`                      | {\"filename\": \"{{ promtail_positions_directory }}/positions.yml\"} | promtail [positions](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#positions) section           |\n| `promtail_config_scrape_configs`                 | []                                                               | promtail [scrape_configs](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#scrape_configs) section |\n| `promtail_target_config`                         | {}                                                               | promtail [target_config](https://grafana.com/docs/loki/latest/clients/promtail/configuration/#target_config) section   |\n| `promtail_log_level`                             | \"info\"                                                           | Loglevel of promtail (one of: `debug`,`info`,`warn`,`error` )                                                          |\n| `promtail_config_include_default_file_sd_config` | \"True\"                                                           | When set to false, the default `file_sd` will not be provisioned                                                       |\n| `promtail_apt_update_cache`                      | \"True\"                                                           | When set to false the role will not update the APT cache on its own                                                    |\n\nFor 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](https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md).\nThe role will converte the ansible vars into the respective yaml configuration for loki.\n\n## Example Playbook\n\nBasic 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:\n\n```yaml\n---\n- hosts: all\n  roles:\n    - role: patrickjahns.promtail\n      vars:\n        promtail_config_scrape_configs:\n          - job_name: system\n            static_configs:\n            - targets:\n                - localhost\n              labels:\n                job: varlogs\n                __path__: /var/log/*log\n```\n\nA more complex example, that overrides server, client, positions configuration and provides a scrap configuration for `/var/log`:\n\n```yaml\n---\n- hosts: all\n  roles:\n    - role: patrickjahns.promtail\n      vars:\n        promtail_config_server:\n          http_listen_port: 9080\n          grpc_listen_port: 9081\n        promtail_config_clients:\n          - url: \"http://prometheus.domain.tld:3100/loki/api/v1/push\"\n            external_labels:\n              host: \"{{ ansible_hostname }}\"\n        promtail_config_positions:\n          filename: \"{{ promtail_positions_directory }}/positions.yaml\"\n          sync_period: \"60s\"\n\n        promtail_config_scrape_configs:\n          - job_name: system\n            static_configs:\n            - targets:\n                - localhost\n              labels:\n                job: varlogs\n                __path__: /var/log/*log\n```\n\n## Local Testing\n\nThe preferred way of locally testing the role is to use Docker and [molecule](https://github.com/metacloud/molecule) (v3.x). You will have to install Docker on your system. See \"Get started\" for a Docker package suitable to for your system.\nWe are using tox to simplify process of testing on multiple ansible versions. To install tox execute:\n```sh\npip3 install tox\n```\nTo run tests on all ansible versions (WARNING: this can take some time)\n```sh\ntox\n```\nTo run a custom molecule command on custom environment with only default test scenario:\n```sh\ntox -e ansible29 -- molecule test -s default\n```\nFor more information about molecule go to their [docs](http://molecule.readthedocs.io/en/latest/).\n\nIf you would like to run tests on remote docker host just specify `DOCKER_HOST` variable before running tox tests.\n\n## CI\n\nGithub actions is used to test and validate this ansible role via [ansible-later](https://github.com/thegeeklab/ansible-later) and [molecule](https://github.com/ansible-community/molecule).\nMolecule tests will run with several operation systems as well as ansible version in order to ensure compatability.\n\n## License\n\nThis project is licensed under MIT License. See [LICENSE](/LICENSE) for more details.\n\n## Maintainers and Contributors\n\n- [Patrick Jahns](https://github.com/patrickjahns)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickjahns%2Fansible-role-promtail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickjahns%2Fansible-role-promtail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickjahns%2Fansible-role-promtail/lists"}