From e46a17e6b5b719259633b12622164b362cdcf9b8 Mon Sep 17 00:00:00 2001 From: Elveg Date: Thu, 16 Jul 2026 16:31:14 +0300 Subject: [PATCH 1/5] fix install (retries, until, delay), add deleting tmp-files and fix permissions for alloy.service --- roles/grafana_alloy/tasks/install.yml | 32 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/roles/grafana_alloy/tasks/install.yml b/roles/grafana_alloy/tasks/install.yml index b274748..0c7304d 100644 --- a/roles/grafana_alloy/tasks/install.yml +++ b/roles/grafana_alloy/tasks/install.yml @@ -23,13 +23,16 @@ block: - name: "Install | Check Alloy version" changed_when: false + failed_when: false ansible.builtin.command: cmd: "alloy --version" register: grafana_alloy_ver - name: "Install | Assert version correctness" ansible.builtin.assert: - that: "grafana_alloy_version in grafana_alloy_ver.stdout" + that: + - "grafana_alloy_ver.rc == 0" + - "grafana_alloy_version in grafana_alloy_ver.stdout" success_msg: "alloy version {{ grafana_alloy_version }} is installed and working" fail_msg: "alloy version {{ grafana_alloy_version }} is not installed or not working correctly" @@ -39,9 +42,20 @@ name: "unzip" state: present - - name: "Install | Fetch and unpack the distribution" + - name: "Install | Download the distribution archive" + ansible.builtin.get_url: + url: "https://github.com/grafana/alloy/releases/download/v{{ grafana_alloy_version }}/alloy-linux-amd64.zip" + dest: "/tmp/alloy-linux-amd64.zip" + timeout: 30 + force: true + register: download_status + until: download_status is success + retries: 3 + delay: 5 + + - name: "Install | Unpack and delete the distribution" ansible.builtin.unarchive: - src: "https://github.com/grafana/alloy/releases/download/v{{ grafana_alloy_version }}/alloy-linux-amd64.zip" + src: "/tmp/alloy-linux-amd64.zip" dest: "/tmp" remote_src: true @@ -56,15 +70,19 @@ mode: "0755" - name: "Install | Clean up the downloads" + loop: + - "/tmp/alloy-linux-amd64" + - "/tmp/alloy-linux-amd64.zip" ansible.builtin.file: - path: "/tmp/alloy-linux-amd64" + path: "{{ item }}" state: absent + - name: "Install | Create a systemd service unit" notify: "(Re)start Alloy service" ansible.builtin.template: src: alloy.service.j2 dest: /etc/systemd/system/alloy.service - owner: "alloy" - group: "alloy" - mode: "0660" + owner: "root" + group: "root" + mode: "0644" From fdb0700e421a72482742db88c722e855f22442a7 Mon Sep 17 00:00:00 2001 From: Elveg Date: Thu, 16 Jul 2026 16:41:34 +0300 Subject: [PATCH 2/5] fix linter --- roles/grafana_alloy/tasks/install.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/grafana_alloy/tasks/install.yml b/roles/grafana_alloy/tasks/install.yml index 0c7304d..48a0fa5 100644 --- a/roles/grafana_alloy/tasks/install.yml +++ b/roles/grafana_alloy/tasks/install.yml @@ -46,10 +46,12 @@ ansible.builtin.get_url: url: "https://github.com/grafana/alloy/releases/download/v{{ grafana_alloy_version }}/alloy-linux-amd64.zip" dest: "/tmp/alloy-linux-amd64.zip" + group: "alloy" + owner: "alloy" timeout: 30 force: true - register: download_status - until: download_status is success + register: grafana_alloy_download_status + until: grafana_alloy_download_status is success retries: 3 delay: 5 From 8f8c56c04e20c41bff9a3973dd429ff536432100 Mon Sep 17 00:00:00 2001 From: Elveg Date: Thu, 16 Jul 2026 16:56:23 +0300 Subject: [PATCH 3/5] fix permissions-linter and kics --- roles/grafana_alloy/tasks/install.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/grafana_alloy/tasks/install.yml b/roles/grafana_alloy/tasks/install.yml index 48a0fa5..14c8c8d 100644 --- a/roles/grafana_alloy/tasks/install.yml +++ b/roles/grafana_alloy/tasks/install.yml @@ -59,6 +59,8 @@ ansible.builtin.unarchive: src: "/tmp/alloy-linux-amd64.zip" dest: "/tmp" + group: "alloy" + owner: "alloy" remote_src: true - name: "Install | Put the binary under the PATH" @@ -87,4 +89,4 @@ dest: /etc/systemd/system/alloy.service owner: "root" group: "root" - mode: "0644" + mode: "0600" From 04e5bc7b50fa6ec6de4d20e8514b6b519fe9988f Mon Sep 17 00:00:00 2001 From: Elveg Date: Thu, 16 Jul 2026 17:10:17 +0300 Subject: [PATCH 4/5] fix spaces and permissions --- roles/grafana_alloy/tasks/install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/grafana_alloy/tasks/install.yml b/roles/grafana_alloy/tasks/install.yml index 14c8c8d..510c9e8 100644 --- a/roles/grafana_alloy/tasks/install.yml +++ b/roles/grafana_alloy/tasks/install.yml @@ -48,6 +48,7 @@ dest: "/tmp/alloy-linux-amd64.zip" group: "alloy" owner: "alloy" + mode: "0644" timeout: 30 force: true register: grafana_alloy_download_status @@ -81,7 +82,6 @@ path: "{{ item }}" state: absent - - name: "Install | Create a systemd service unit" notify: "(Re)start Alloy service" ansible.builtin.template: From 5eeec4ad308c88ed70979772942ad157a17cebfa Mon Sep 17 00:00:00 2001 From: Elveg Date: Thu, 16 Jul 2026 17:13:42 +0300 Subject: [PATCH 5/5] fix space --- roles/grafana_alloy/tasks/install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/grafana_alloy/tasks/install.yml b/roles/grafana_alloy/tasks/install.yml index 510c9e8..d95fe6f 100644 --- a/roles/grafana_alloy/tasks/install.yml +++ b/roles/grafana_alloy/tasks/install.yml @@ -30,7 +30,7 @@ - name: "Install | Assert version correctness" ansible.builtin.assert: - that: + that: - "grafana_alloy_ver.rc == 0" - "grafana_alloy_version in grafana_alloy_ver.stdout" success_msg: "alloy version {{ grafana_alloy_version }} is installed and working"