# Template replacement

**URL:** <https://forum.ansible.com/t/template-replacement/21428>\
**Category:** Ansible Project\
**Created:** [May 13, 2016, 1:43am UTC](https://forum.ansible.com/t/template-replacement/21428 "2016-05-13T01:43:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pushparaj\_BS](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Pushparaj\_BS](https://forum.ansible.com/u/Pushparaj_BS)\
**Post date:** [May 13, 2016, 1:43am UTC](https://forum.ansible.com/t/template-replacement/21428/1 "2016-05-13T01:43:37Z")

</div>

Have a template which updates the host name of an webserver configuration file .  
I'm good here , the host gets updated properly. I use the template src tag to do this.

After this task ,the deployment task runs for the application which puts an entry into the webserver configuration file .

When I rerun the playbook , the template task notifies as changed since , on the server it was updated in the last run.It thus again copies the template again , which overwrites the deployment entry done last run.

How can tell Ansible ignore extra changes on the file from webserver deployment persoective, but still get changes from template if anything extra added in ansible source

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 13, 2016, 8:21pm UTC](https://forum.ansible.com/t/template-replacement/21428/2 "2016-05-13T20:21:59Z")

</div>

Do not use the template module, as it changes the whole file. If you  
just have to change one value, use the lineinfile module to change one  
line in the file.

[https://docs.ansible.com/ansible/lineinfile\_module.html](https://docs.ansible.com/ansible/lineinfile_module.html)

I think there is no way to get the behaviour you describe, I could  
only imagine creating a bash script or similar that compares the two  
files and ignores your later deployment changes. But that feels like a  
hack...

Johannes
