On 23.03.2018 07:10, GURU W wrote:
> Hi All,
>
> I know ansible is for configuration management, provisioning, task
> automation. Ansible is already use to solve the purpose.
>
>
> *Background:* I have shell scripts to read a filename from source and
> copying them to declared target location.
>
> *Ex:* "xyz_date_123.txt" (script does the task of reading the date in
> the
> filename and creates target directory aswel, later places the file
> inside
> destination say: Project/YYYY/MM/DD directory)
>
>
> I was wondering if we could do this using ansible, I have "functions",
> "if", "else" statements. Wasn't sure if we could use ansible to solve
> this
> purpose.
>
> Expert advice would be most appreciated.
It's doable.
find module to find the file, .split [1] on the filename to get the date
out and then some slicing of the result to get the year, month and day.
Then it's just using fetch and/or copy module depending where the file
should be copied to.
[1]
https://docs.python.org/2/library/stdtypes.html#str.split
--
Kai Stian Olstad