# revert changes in specific file using ansible.

**URL:** <https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738>\
**Category:** Ansible Project\
**Created:** [June 7, 2018, 3:22pm UTC](https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738 "2018-06-07T15:22:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hasan\_Syed](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@Hasan\_Syed](https://forum.ansible.com/u/Hasan_Syed)\
**Post date:** [June 7, 2018, 3:22pm UTC](https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738/1 "2018-06-07T15:22:33Z")

</div>

Team,  
Could you please guide me how we can revert changes of a remote server file using ansible? like I have a file on server 1 abc.txt and someone have changed it my requirement is to make the abc.txt file in previous status using ansible.

Thanks,

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [June 7, 2018, 4:18pm UTC](https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738/2 "2018-06-07T16:18:14Z")

</div>

If someone made the change to a config outside of ansible, re-running the ansible playbook will restore the config to what is in the playbook.

---

<div class="post-metadata">

**Author:** ![Hasan\_Syed](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@Hasan\_Syed](https://forum.ansible.com/u/Hasan_Syed)\
**Post date:** [June 7, 2018, 4:28pm UTC](https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738/3 "2018-06-07T16:28:26Z")

</div>

Thanks, means we can not automate things like ansible keep monitoring the config file and revert it to original state if someone make any changes.

---

<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:** [June 7, 2018, 4:44pm UTC](https://forum.ansible.com/t/revert-changes-in-specific-file-using-ansible/27738/4 "2018-06-07T16:44:31Z")

</div>

You can, many ways:

- schedule Ansible runs that set the file to the 'correct' version  
(this is mostly how other CM tools do it)  
- have a FAM (file alteration monitor: gam, aide, osiris, tripwire,  
incron) trigger an Ansible run to update/correct the file  
- run Ansible on a schedule with --check mode to notify you on  
changes and rerun manually/automatically to do remediation

For schedule/triggering you can use many tools, including Tower/AWX, I  
also recomend etckeeper as a tool to keep track of changes to local  
configs.
