I am writing an Ansible playbook that checks and downloads RPM packages of certain versions and patch levels.
I want to make the playbook to stop when there are no new files, so I thought I should try it with stat.
For better understanding, this is what I got:
list1(Major Versions of the package)- 13.0
- 13.1
- 13.2
list2(Patchversions of the supported major versions)- 13.0.0
- 13.0.1
- 13.0.2
- ...
- 13.1.0
- 13.1.1
- 13.1.2
- ...
- 13.2.0
- 13.2.1
- 13.2.2
- ...
My tasks looks like this:
- name: check if file already exists
stat:
path: /var/www/html/softwarexyz/{{ item[0] }}/{{ date }}/software-xyz-{{ item[1] }}-xyz.0.x86_64.rpm
with_nested:
- "{{ list1.stdout_lines[:] }}"
- "{{ list2.stdout_lines[:] }}"
register: stat_results
Ansible does the following:
Check if in folder of version 13.0 all items out of list2 are somehow there, same for 13.1 and 13.2. Of course it makes no sense, that ansible looks in folder 13.0 for versions starting with 13.1 or 13.2.
How do I make this more efficient? As it takes alot of time to check, depending on the list size.