On 13/03/2023 17:39, Hiero-nymo 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 }}
Hello, you need to quote the argument for the loop:
loop: '{{ file }}'
Regards
Racke
--
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://groups.google.com/d/msgid/ansible-project/3419395b-36b0-4195-9278-de959fa763can%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper
--
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/c3f29330-5459-ea46-c912-eee5ed0c0eb3%40linuxia.de.