Do not create download dir with recurse; check if dir already exists

The recurse parameter is not needed there.
Also added condition that check if directory already exists to avoid
error on old Ansible, where some directories inside the download dir
disappear.

Change-Id: I211c62d05ef3bea23654364b6bbe5bbf2d9e11c3
This commit is contained in:
Daniel Pawlik 2024-09-27 13:18:53 +02:00
parent 17d6727d42
commit 0d5bf1c13e
No known key found for this signature in database

View File

@ -1,12 +1,19 @@
---
- name: Create logscraper download directory
file:
path: "{{ item.download_dir }}"
state: directory
recurse: true
owner: "{{ logscraper_user }}"
group: "{{ logscraper_group }}"
when: "'download_dir' in item"
block:
- name: Check if download directory already exists
ansible.builtin.stat:
path: "{{ item.download_dir }}"
register: _download_dir
- name: Create download directory
when: not _download_dir.stat.exists
ansible.builtin.file:
path: "{{ item.download_dir }}"
state: directory
owner: "{{ logscraper_user }}"
group: "{{ logscraper_group }}"
- name: Generate logscraper script
template: