# How can I make this work?

**URL:** <https://forum.ansible.com/t/how-can-i-make-this-work/26518>\
**Category:** Ansible Developer\
**Created:** [January 19, 2018, 11:56am UTC](https://forum.ansible.com/t/how-can-i-make-this-work/26518 "2018-01-19T11:56:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pranay\_Nanda](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@Pranay\_Nanda](https://forum.ansible.com/u/Pranay_Nanda)\
**Post date:** [January 19, 2018, 11:56am UTC](https://forum.ansible.com/t/how-can-i-make-this-work/26518/1 "2018-01-19T11:56:38Z")

</div>

Hi! I’m still learning Ansible. I need help with recursively replacing strings in a directory.

Will this code work?

`- replace:`  
`dest: "/home/ansible/cloning/*"`  
`regexp: "{{ansible_hostname}}"`  
`replace: "{{ansible_system}"`  
`with_filetree: "/home/ansible/cloning/"`

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 22, 2018, 10:19pm UTC](https://forum.ansible.com/t/how-can-i-make-this-work/26518/2 "2018-03-22T22:19:57Z")

</div>

you need to specify the file, which is contained in the 'item'  
variable produced by the loop:

- replace:  
&nbsp;&nbsp;&nbsp;dest: "/home/ansible/cloning/{{item}}"  
&nbsp;&nbsp;&nbsp;&nbsp;regexp: "{{ansible\_hostname}}"  
&nbsp;&nbsp;&nbsp;&nbsp;replace: "{{ansible\_system}"  
&nbsp;&nbsp;with\_filetree: "/home/ansible/cloning/"
