You are not registering the product of the task.
find:
paths: /tmp
recurse: false
file_type_ file
patterns: '^{{ item.filename }}\.[0-9]{6}.*$'
use_regex: yes
loop: {{ file }}
register: found
You then need to look at found.files (a list) to see what is found. This is
documented in the ansible find module.
Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123
On Mar 13, 2023, at 12:39 PM, Hiero-nymo <[email protected]> wrote:
Hi everyone,
I've tried to using a variable in find module by pattern by it doesn't seems to
work. Here's below a example. I also looked at another solution with set_facts
but I doesn't run too.
I want to list all the backup files in a directory. The files have a timestamp
and it's filename will be defined by variable.
Does anyone have an idea how should I proceed? or in which way?
Thanks in advance for your help
Here's the variables:
---
file:
- filename: backup
state: present
[...]
Here's the task:
---
[...]
find:
paths: /tmp
recurse: false
file_type_ file
patterns: '^{{ item.filename }}\.[0-9]{6}.*$'
use_regex: yes
loop: {{ file }}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3419395b-36b0-4195-9278-de959fa763can%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2F3419395b-36b0-4195-9278-de959fa763can%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C5a7a38ffb28f4da9522508db23e18b8b%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638143223859421123%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vBy3M%2Fz2f4Eec5SakygkzK5YMrkhyVLshIHWz8qUN%2Bw%3D&reserved=0>.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7E9B8E33-5171-4B7B-80D0-8AAEEA6A7E44%40nist.gov.