# help with yaml file

**URL:** <https://forum.ansible.com/t/help-with-yaml-file/35303>\
**Category:** Ansible Project\
**Created:** [June 8, 2021, 6:20am UTC](https://forum.ansible.com/t/help-with-yaml-file/35303 "2021-06-08T06:20:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinod\_P](https://avatars.discourse-cdn.com/v4/letter/v/d07c76/32.png) [@Vinod\_P](https://forum.ansible.com/u/Vinod_P)\
**Post date:** [June 8, 2021, 6:20am UTC](https://forum.ansible.com/t/help-with-yaml-file/35303/1 "2021-06-08T06:20:30Z")

</div>

Hello All,  
Need some help with yaml file

I am trying to run find command to fetch old IP address from multiple files in /etc directory and replace them with new IP address as follows

sudo find /etc -type f -exec sed -i -e ‘s/10.1.3.51/10.2.3.54/g’ {} +

I can accomplish this using the command but how do I do it using yaml file as i need to run it on multiple servers.

Please help and thanks in advance.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 8, 2021, 6:45am UTC](https://forum.ansible.com/t/help-with-yaml-file/35303/2 "2021-06-08T06:45:32Z")

</div>

> in /etc directory and replace them with new IP address as follows  
> sudo find /etc -type f -exec sed -i -e 's/10.1.3.51/10.2.3.54/g' {} +

For example, given the file

> cat etc/file1

10.1.3.50  
10.1.3.51  
10.1.3.52

the playbook

> cat test-007.yml

- hosts: localhost  
&nbsp;&nbsp;gather\_facts: false  
&nbsp;&nbsp;become: true  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- find:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: etc  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file\_type: file  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recurse: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: result  
&nbsp;&nbsp;&nbsp;&nbsp;- replace:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: "{{ item }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;regexp: "10.1.3.51"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;replace: "10.2.3.54"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop: "{{ result.files|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map(attribute='path')|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list }}"

gives

> ansible-playbook test-007.yml -CD

PLAY [localhost]
