# Using ansible data management. I have use case to solve.

**URL:** <https://forum.ansible.com/t/using-ansible-data-management-i-have-use-case-to-solve/27089>\
**Category:** Ansible Project\
**Created:** [March 23, 2018, 6:10am UTC](https://forum.ansible.com/t/using-ansible-data-management-i-have-use-case-to-solve/27089 "2018-03-23T06:10:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GURU\_W](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@GURU\_W](https://forum.ansible.com/u/GURU_W)\
**Post date:** [March 23, 2018, 6:10am UTC](https://forum.ansible.com/t/using-ansible-data-management-i-have-use-case-to-solve/27089/1 "2018-03-23T06:10:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 23, 2018, 11:26am UTC](https://forum.ansible.com/t/using-ansible-data-management-i-have-use-case-to-solve/27089/2 "2018-03-23T11:26:35Z")

</div>

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](https://docs.python.org/2/library/stdtypes.html#str.split)
