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
ansible notices that the file doesn't have the correct output, tries to change it but does not recognise that updating the file fails. because of this, subsequent calls of the same action still return "changed" status - allthough nothing happened.
Expected Results:
On I/O errors, fail.
Actual Results:
ignores I/O error silently.
one could argue that using the "validate_checksum" flag makes ansible fail this action instead of silently skipping it. In my opinion, the validate_checksum flag should be used to ensure that the source file didn't change in the meantime and that a full, consistent file was fetched, but should not guard against programming errors in ansible itself.
Quick and Dirty Patch
The following patch makes ansible fail this action instead of silently skipping the problem. The status message could be improved...
diff --git a/lib/ansible/plugins/action/fetch.py b/lib/ansible/plugins/action/fetch.py
index fb2d545..35294a2 100644
--- a/lib/ansible/plugins/action/fetch.py
+++ b/lib/ansible/plugins/action/fetch.py
@@ -133,9 +133,12 @@ class ActionModule(ActionBase):
if remote_data is None:
self._connection.fetch_file(source, dest)
else:
- f = open(dest, 'w')
- f.write(remote_data)
- f.close()
+ try:
+ f = open(dest, 'w')
+ f.write(remote_data)
+ f.close()
+ except:
+ return dict(failed=True, msg="file write error")
new_checksum = secure_hash(dest)
# For backwards compatibility. We'll return None on FIPS enabled
# systems
The text was updated successfully, but these errors were encountered:
We believe the above commit should resolve this problem for you. This will also be included in the next major release.
If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:
Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.
Issue Type:
Bug Report
Ansible Version:
Ansible Configuration:
nothing important changed from the upstream example, only the defaults.inventory and defaults.remote_user settings.
Environment
N/A (Debian Jessie on amd64)
Summary:
When fetching a file from the remote host which can not be written locally, the write fails silently.
Steps To Reproduce:
Below, I just execute the same fetch command multiple times:
the first call fetches the file, and has the status "changed"
the second call doesn't change anything, everything is well. now reproduce the problem: change the file locally and make it unwritable
ansible notices that the file doesn't have the correct output, tries to change it but does not recognise that updating the file fails. because of this, subsequent calls of the same action still return "changed" status - allthough nothing happened.
Expected Results:
On I/O errors, fail.
Actual Results:
ignores I/O error silently.
one could argue that using the "validate_checksum" flag makes ansible fail this action instead of silently skipping it. In my opinion, the validate_checksum flag should be used to ensure that the source file didn't change in the meantime and that a full, consistent file was fetched, but should not guard against programming errors in ansible itself.
Quick and Dirty Patch
The following patch makes ansible fail this action instead of silently skipping the problem. The status message could be improved...
The text was updated successfully, but these errors were encountered: