alloy(role): pull in alloy role that works from fux
All checks were successful
/ build (pull_request) Successful in 32s
/ Ansible Lint (push) Successful in 2m23s
/ Ansible Lint (pull_request) Successful in 2m25s

This commit is contained in:
chris 2026-07-09 21:13:57 +02:00
commit 0b5fa03ac3
Signed by: c6ristian
SSH key fingerprint: SHA256:B3m+yzpaxGXSEcDBpPHfvza/DNC0wuX+CKMeGq8wgak
246 changed files with 555 additions and 19211 deletions

View file

@ -1,50 +1,79 @@
# https://github.com/grafana/grafana-ansible-collection/blob/main/roles/alloy/tasks/deploy.yml#L124
- name: ensure alloy user exists
ansible.builtin.user:
name: alloy
system: true
append: true
create_home: false
state: present
- name: ensure the `/etc/alloy/` config directory exists
ansible.builtin.file:
path: /etc/alloy
state: directory
mode: "0770"
owner: root
group: alloy
become: true
- name: synchronize the additional configuration files directory, if present
when: alloy__additional_configs_dir is defined and alloy__additional_configs_dir != ""
---
- name: Deploy Grafana Alloy with config
tags: [ alloy ]
block:
- name: ensure rsync is installed
ansible.builtin.apt:
name: rsync
- name: Install Alloy on Debian
when: ansible_facts['distribution'] == "Debian"
ansible.builtin.include_tasks: install_debian.yml
- name: Create systemd override for alloy
become: true
when: alloy_cap_net_bind_service
notify: Systemd.daemon_reload
block:
- name: Create systemd override directory
ansible.builtin.file:
path: /etc/systemd/system/alloy.service.d
state: directory
mode: "0755"
owner: root
group: root
- name: Add CAP_NET_BIND_SERVICE capability
ansible.builtin.copy:
dest: /etc/systemd/system/alloy.service.d/override.conf
mode: "0755"
owner: root
group: root
content: |
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
- name: synchronize the additional configuration files directory, if present
ansible.posix.synchronize:
src: "{{ alloy__additional_configs_dir }}"
dest: /etc/alloy/additional
delete: true
recursive: true
use_ssh_args: true
rsync_opts:
- "--chown=root:alloy"
- name: Deploy the Alloy config file
become: true
ansible.builtin.template:
src: "config.alloy.j2"
dest: "/etc/alloy/config.alloy"
owner: "alloy"
group: "alloy"
mode: "0640"
notify:
- Alloy.restarted
- Alloy.enabled
- name: delete the additional configuration files directory, if not present
when: alloy__additional_configs_dir is not defined or alloy__additional_configs_dir == ""
ansible.builtin.file:
path: /etc/alloy/additional
state: absent
become: true
- name: Validate Alloy configuration and print error if failed
block:
- name: Validate Alloy configuration
become: true
register: alloy_validation
changed_when: false
ansible.builtin.command: alloy validate /etc/alloy/config.alloy
rescue:
- name: Show error if validation failed
when: alloy_validation.rc != 0
ansible.builtin.fail:
msg: |
Alloy configuration validation failed!
Return code: {{ alloy_validation.rc }}
Stdout:
{{ alloy_validation.stdout }}
Stderr:
{{ alloy_validation.stderr }}
- name: Setup Alloy
ansible.builtin.import_role:
name: grafana.grafana.alloy
vars:
alloy_config: "{{ alloy_config_default ~ alloy_config_additional }}"
become: true
- name: Deploy blackbox-exporter config
when: alloy_enable_blackbox_exporter
ansible.builtin.include_tasks: blackbox-exporter.yaml
- name: Deploy unpoller exporter
when: alloy_unpoller_enabled
ansible.builtin.include_tasks: unpoller.yaml
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Ensure that Alloy is working
ansible.builtin.uri:
url: "http://localhost:12345/-/ready"
method: GET
register: alloy_status_code
retries: 8
delay: 6
until: not alloy_status_code.failed