X
X
xp1eo2020-05-26 19:35:24
Automation
xp1eo, 2020-05-26 19:35:24

Checking a filename for a timestamp and what to do next?

Good afternoon.
Please help in the following situation: It is
necessary to register the following action mechanism in the playbook:

1) The playbook looks in the directory, looking for .yml files
2) If it finds it, it looks at the file name.
Based on the file name, 2 actions are performed:
a) if the file name contains a time stamp of the YYYY-MM-DD-HH:MM:SS format, then it writes the name of this playbook to another file.
b) if there is no timestamp in the playbook name, then it is instantly executed.

If there is no problem with capturing the name - find or fileglob does a great job with this, then it is not clear what to do with the reaction to the file name.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sanes, 2020-05-26
@Sanes

Run find via command. put stdout into a variable.

M
MaxKozlov, 2020-05-26
@MaxKozlov

command is evil. the module is
https://docs.ansible.com/ansible/latest/modules/fi...
and there are the necessary regexes
or you can filter what the module has already found via select()

P
Puma Thailand, 2020-05-27
@opium

Why do you have these hemorrhoids?
Describe the initial task and I think you will be offered a bunch of correct solutions, otherwise it’s from the category of Frankenstein

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question