You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a command (or shell) task is meant to modify a file -- in a way, for which no other tasks exist (beyond lineinfile or patch), there are following problems:
A status of the task is always "changed" by default, even when it made no changes.
There is no way to see the "diff" of the modified files -- without implementing multiple tasks for it.
Solution proposal
Similar to the already-present creates clause, the module could have an updates clause, which shall cause Ansible to diff the listed file(s) and to automatically set changed to False, if no changes actually took place.
- name: Run the reportscommand: runreports.shupdates:
- /prod/reports/sales.csv
- /prod/reports/accounting.csv
- name: Dump my tableshell: isql -b > dump.txtargs:
stdin: |- SELECT * FROM MYTABLE goupdates: dump.txt
Documentation (optional)
Parameter
Choices/Defaults
Comments
updates (path)
A filename or glob pattern -- or a list of such. The task will be considered unchanged, if none of the listed files are modified. If "diff" is requested, these files will be compared to their older versions.
The text was updated successfully, but these errors were encountered:
Add
updates
clause tocommand
andshell
modulesAuthor: United Marsupials <@UnitedMarsupials>
Date: 20210-05-15
Motivation
Make
command
andshell
modules more usefulProblems
When a
command
(orshell
) task is meant to modify a file -- in a way, for which no other tasks exist (beyondlineinfile
orpatch
), there are following problems:Solution proposal
Similar to the already-present
creates
clause, the module could have anupdates
clause, which shall cause Ansible to diff the listed file(s) and to automatically setchanged
toFalse
, if no changes actually took place.Documentation (optional)
updates
(path)The text was updated successfully, but these errors were encountered: