New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix --diff to produce output when creating a new file #57744
Conversation
@@ -1104,7 +1104,7 @@ def _get_diff_data(self, destination, source, task_vars, source_file=True): | |||
|
|||
if not peek_result.get('failed', False) or peek_result.get('rc', 0) == 0: | |||
|
|||
if peek_result.get('state') == 'absent': | |||
if peek_result.get('state') is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would do both in ('absent', None)
as there are cases in which 'absent' would be a correct return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there are. peek_result
is a result of the file module being executed with _diff_peek=True
which just checks if the file is binary and calls exit_json
. From there add_path_info
is only method that modifies state
in the result and no longer sets absent
.
Having said that doing in ('absent', None)
might be more defensive, so I'd be +1 for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also have to take into account actions that have 'remote_src=true' as they might not rely on peek
* Fix --diff to produce output when creating a new file Fixes ansible#57618 * Make the check more defensive (cherry picked from commit 1fa7bfc)
* Fix --diff to produce output when creating a new file Fixes ansible#57618 * Make the check more defensive
SUMMARY
#51350 removed apending
state: absent
for missing files in the module's result. However_get_diff_data
method was specifically checking forabsent
in the result. This changes that to check for missingstate
key instead.This needs to be backported to
2.8
if merged.Fixes #57618
ISSUE TYPE
COMPONENT NAME
lib/ansible/plugins/action/__init__.py