From 3b3dfa2f2e182c8a6485ec2a9b717aa35fa514ad Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Sun, 28 Dec 2025 20:04:40 +0400 Subject: [PATCH] Move the directory creation task outside of block/rescue --- roles/prometheus/tasks/install.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/roles/prometheus/tasks/install.yml b/roles/prometheus/tasks/install.yml index 03877de..f0662b9 100644 --- a/roles/prometheus/tasks/install.yml +++ b/roles/prometheus/tasks/install.yml @@ -7,7 +7,19 @@ create_home: false state: present -- name: "Install | Install the binary" +- name: "Install | Create directories {{ item }}" + loop: + - "{{ prometheus_config_dir }}" + - "{{ prometheus_config_dir }}/rules" + - "{{ prometheus_db_dir }}" + ansible.builtin.file: + path: "{{ item }}" + state: directory + owner: "prometheus" + group: "prometheus" + mode: "0755" + +- name: "Install | Install the binaries" block: - name: "Install | Check Prometheus version" changed_when: false @@ -22,18 +34,6 @@ fail_msg: "prometheus version {{ prometheus_version }} is not installed or not working correctly" rescue: - - name: "Install | Create directories {{ item }}" - with_items: - - "{{ prometheus_config_dir }}" - - "{{ prometheus_config_dir }}/rules" - - "{{ prometheus_db_dir }}" - ansible.builtin.file: - path: "{{ item }}" - state: directory - owner: "prometheus" - group: "prometheus" - mode: "0755" - - name: "Install | Fetch and unpack the distribution" notify: "(Re)start Prometheus service" ansible.builtin.unarchive: