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

27 views
Skip to first unread message

Cev Ing

unread,
Jan 30, 2017, 5:49:39 AM1/30/17
to Ansible Project
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?

Brian Coca

unread,
Jan 30, 2017, 1:33:51 PM1/30/17
to ansible...@googlegroups.com
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.

--
----------
Brian Coca

Cev Ing

unread,
Feb 6, 2017, 9:06:25 AM2/6/17
to Ansible Project


Am Montag, 30. Januar 2017 19:33:51 UTC+1 schrieb Brian Coca:
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.


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

Brian Coca

unread,
Feb 6, 2017, 9:14:40 AM2/6/17
to Ansible Project
copy itself executes the stat module to decide to copy or not


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages