Add grafana_alloy role: scrape log files to Loki

This commit is contained in:
2026-07-06 13:07:50 +03:00
parent 5322a48353
commit bafa282482
11 changed files with 264 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
- name: Converge
hosts: all
roles:
- role: genlab.common.grafana_alloy

View File

@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: rocky
image: geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -0,0 +1,43 @@
---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
tasks:
- name: "Include default vars"
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
extensions: ['yml']
- name: "Check if Alloy is installed"
changed_when: false
ansible.builtin.command: "alloy --version"
register: grafana_alloy_installed_version
- name: "Check Alloy version"
ansible.builtin.assert:
that: "grafana_alloy_version in grafana_alloy_installed_version.stdout"
success_msg: "Alloy version {{ grafana_alloy_version }} is available and executable"
fail_msg: "Alloy version {{ grafana_alloy_version }} not found or not executable"
- name: "Check if Alloy service is active"
ansible.builtin.systemd:
name: alloy
register: grafana_alloy_service
failed_when: "grafana_alloy_service.status.ActiveState != 'active'"
# kics-scan ignore-block
- name: "Check if Alloy is ready"
ansible.builtin.uri:
url: "http://localhost:12345/-/ready"
return_content: true
status_code: 200
method: GET
register: grafana_alloy_ready
- name: "Assert Alloy readiness"
ansible.builtin.assert:
that: "grafana_alloy_ready.content | trim == 'Alloy is ready.'"
success_msg: "Alloy is ready"
fail_msg: "Alloy is not ready"