loki_canary
Ansible Role: loki_canary
Description
Deploy loki canary using ansible. For recent changes, please check the CHANGELOG or have a look at github releases
Requirements
- Ansible >= 2.7
Role Variables
All variables which can be overridden are stored in defaults/main.yml file as well as in table below.
For configuration values related to canary itself, please refer to the canary section in the loki documentation
Name | Default Value | Description |
---|---|---|
canary_version |
"2.0.0" | canary package version. Also accepts latest as parameter. |
canary_system_user |
loki-canary | User the canary process will run at |
canary_system_group |
"{{ canary_system_user }}" | Group of the canary user |
canary_install_dir |
"/opt/loki-canary" | Directory where canary binaries will be installed |
canary_tmp_dir |
"/tmp" | Directory for temporary files during installation |
canary_config_addr |
"" | REQUIRED loki server address - more information |
canary_config_port |
3500 | Port where canary will expose metrics - more information |
canary_config_buckets |
"" | See canary configuration |
canary_conig_interval |
"" | See canary configuration |
canary_config_labelname |
"" | See canary configuration |
canary_config_labelvalue |
"" | See canary configuration |
canary_config_pruneinterval |
"" | See canary configuration |
canary_config_size |
"" | See canary configuration |
canary_config_wait |
"" | See canary configuration |
canary_config_user |
"" | See canary configuration |
canary_config_pass |
"" | See canary configuration |
canary_redirect_stdout |
"False" | Enable workaround to use canary with systemd |
canary_promtail_sd_file |
"/etc/promtail/file_sd/canary.yml" | File service discovery file to write for promtail to discover |
canary_promtail_file_path |
"/tmp/canary.log" | Logfile to be written by canary and to be parsed by promtail |
Role Tags
The following tags are specified in the role and can be selected/skipped during playbook runs
canary
- general tag that is attached to all tasks/handlerscanary_preflight
- attached to all preflight tasks (fetching shasums etc.)canary_install
- attached to all install taskscanary_run
- attached to the tasks that starts the canary service
Example Playbook
Basic playbook that will assume that loki will be listening at http://127.0.0.1:3100
---
- hosts: all
roles:
- role: patrickjahns.loki_canary
vars:
canary_config_addr: "http://127.0.0.1:3100"
More complex example, that configures several parameters of loki canary
---
- hosts: all
roles:
- role: patrickjahns.loki_canary
vars:
canary_config_addr: "http://127.0.0.1:3100"
canary_config_port: 9000
canary_config_wait: 3m
canary_config_user: "test"
canary_config_pass: "test"
canary_config_labelname: "canary_host"
canary_config_labelname: {{ ansible_hostname }}
Example to setup canary with systemd to workaround upstream label issues
---
- hosts: all
roles:
- role: patrickjahns.loki_canary
vars:
canary_config_addr: "http://127.0.0.1:3100"
canary_redirect_stdout: True
canary_config_labelname: "canary_host"
canary_config_labelvalue: "{{ ansible_hostname }}"
Local Testing
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.
CI
Travis
Combining molecule and travis CI allows us to test how new PRs will behave when used with multiple ansible versions and multiple operating systems. This also allows use to create test scenarios for different role configurations. As a result we have a quite large test matrix which will take more time than local testing, so please be patient.
Github Actions
Additionally to TravisCI some github actions are run to perform static code analysis
License
This project is licensed under MIT License. See LICENSE for more details.
Maintainers and Contributors
Deploy (loki) canary
ansible-galaxy install patrickjahns/ansible-role-loki-canary