From 1f4eb2160b6edf06da30c9bca4c727485ed6e096 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Thu, 9 May 2024 09:53:03 -0700 Subject: [PATCH] [stable-2.16] assemble: fixed missing parameter error (#83124) * content is an optional parameter for _get_diff_data API Fixes: #82359 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/82359_assemble_diff.yml | 3 +++ lib/ansible/plugins/action/__init__.py | 2 +- test/integration/targets/assemble/tasks/main.yml | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/82359_assemble_diff.yml diff --git a/changelogs/fragments/82359_assemble_diff.yml b/changelogs/fragments/82359_assemble_diff.yml new file mode 100644 index 00000000000..e3bf64f1a46 --- /dev/null +++ b/changelogs/fragments/82359_assemble_diff.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - assemble - fixed missing parameter 'content' in _get_diff_data API (https://github.com/ansible/ansible/issues/82359). diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 5ba3bd78bb2..2ae5232ad78 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -1339,7 +1339,7 @@ class ActionBase(ABC): display.debug(u"_low_level_execute_command() done: rc=%d, stdout=%s, stderr=%s" % (rc, out, err)) return dict(rc=rc, stdout=out, stdout_lines=out.splitlines(), stderr=err, stderr_lines=err.splitlines()) - def _get_diff_data(self, destination, source, task_vars, content, source_file=True): + def _get_diff_data(self, destination, source, task_vars, content=None, source_file=True): # Note: Since we do not diff the source and destination before we transform from bytes into # text the diff between source and destination may not be accurate. To fix this, we'd need diff --git a/test/integration/targets/assemble/tasks/main.yml b/test/integration/targets/assemble/tasks/main.yml index 14eea3f34a2..add95f936d0 100644 --- a/test/integration/targets/assemble/tasks/main.yml +++ b/test/integration/targets/assemble/tasks/main.yml @@ -152,3 +152,19 @@ that: - "result.state == 'file'" - "result.checksum == '505359f48c65b3904127cf62b912991d4da7ed6d'" + +- name: test assemble with diff + assemble: + src: "./" + dest: "{{remote_tmp_dir}}/assembled11" + remote_src: false + diff: true + register: result + +- name: assert the fragments were assembled with diff + assert: + that: + - result.changed + - result.diff.after is defined + - result.diff.before is defined + - "result.state == 'file'"