# How to prepare a task, which will do a change?

**URL:** <https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593>\
**Category:** Ansible Project\
**Created:** [January 30, 2017, 10:49am UTC](https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593 "2017-01-30T10:49:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [January 30, 2017, 10:49am UTC](https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593/1 "2017-01-30T10:49:39Z")

</div>

I have a task, which replaces a shared library on a system. But before I copy the shared library, I want do deactivate the library in a configuration file. But I do not want to deactivate the library, if it is already up-to-date. How can I conditionally execute a task based on the information, that a succeeding task will do a change? Or how can I just compare files?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 30, 2017, 6:33pm UTC](https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593/2 "2017-01-30T18:33:36Z")

</div>

The stat module returns checksums and you can compare those to verify the file, then proceed as needed. This is what copy uses internally to make the same decision.

---

<div class="post-metadata">

**Author:** ![Cev\_Ing](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@Cev\_Ing](https://forum.ansible.com/u/Cev_Ing)\
**Post date:** [February 6, 2017, 2:06pm UTC](https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593/3 "2017-02-06T14:06:25Z")

</div>

I run now copy with `check_mode: true`. Seems to be easier.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 6, 2017, 2:14pm UTC](https://forum.ansible.com/t/how-to-prepare-a-task-which-will-do-a-change/23593/4 "2017-02-06T14:14:34Z")

</div>

copy itself executes the stat module to decide to copy or not
