Re: [ansible-project] Identify most recent directory in a directory.

2022-12-22 Thread Thanh Nguyen Duc
I don’t think you can achieve what you want if the file keep generating. Ansible is not real time monitor/scanning. The most recently at the point of time when you trigger only. Thanks and Best Regards, Thanh. > On 23 Dec 2022, at 11:55, Nico Kadel-Garcia wrote: > > On Thu, Dec 1, 2022 at

Re: [ansible-project] Identify most recent directory in a directory.

2022-12-22 Thread Nico Kadel-Garcia
On Thu, Dec 1, 2022 at 7:10 PM Vladimir Botka wrote: > > Use Ansible module *find* and sort the directories by *ctime*. For > example, given the tree This is only reliable if nothing else writes anything else in that tree between the first command, tand the "tree" command. > shell> tree /tmp/te

Re: [ansible-project] Identify most recent directory in a directory.

2022-12-01 Thread Vladimir Botka
Use Ansible module *find* and sort the directories by *ctime*. For example, given the tree shell> tree /tmp/test /tmp/test ├── 2022-12-01_1701 ├── 2022-12-01_1702 └── 2022-12-01_1703 Declare the variable last_dir: "{{ (out.files|sort(attribute='ctime')|last).path }}" The tasks below - fi

Re: [ansible-project] Identify most recent directory in a directory.

2022-12-01 Thread Thanh Nguyen Duc
Is it the shell script also be triggered via ansible? If yes then you can register the path and work with it later. If not then do you know roughly when script be triggered then can just use shell command to find the directory with created date. Sent from my iPhone > On 2 Dec 2022, at 05:57, J

[ansible-project] Identify most recent directory in a directory.

2022-12-01 Thread Jason Wood
After performing a shell script, a new directory is created and I need to work with that directory, but I don't know the name. How can I get the name of the most recent directory created? The name will be formatted like 2022-12-01_1702, so the directory I need will be the last if sorted alphanu