From 4bfb832f0d6ae75e84fca09bb33ba8d0b841d349 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 07:55:46 +0200 Subject: [PATCH] [PR #8476/2612ceee backport][stable-8] Fix launchd check-mode to report changed correctly (#8528) Fix launchd check-mode to report changed correctly (#8476) * Fix launchd check-mode to report changed correctly * Update changelog fragment. --------- Co-authored-by: Strahinja Kustudic Co-authored-by: Felix Fontein (cherry picked from commit 2612ceee3722d25810ceb805726b9c2e517a0985) Co-authored-by: Strahinja Kustudic --- changelogs/fragments/8476-launchd-check-mode-changed.yaml | 2 ++ plugins/modules/launchd.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8476-launchd-check-mode-changed.yaml diff --git a/changelogs/fragments/8476-launchd-check-mode-changed.yaml b/changelogs/fragments/8476-launchd-check-mode-changed.yaml new file mode 100644 index 0000000000..dc1e60de36 --- /dev/null +++ b/changelogs/fragments/8476-launchd-check-mode-changed.yaml @@ -0,0 +1,2 @@ +bugfixes: + - launched - correctly report changed status in check mode (https://github.com/ansible-collections/community.general/pull/8406). diff --git a/plugins/modules/launchd.py b/plugins/modules/launchd.py index e5942ea7cf..a6427bdb2f 100644 --- a/plugins/modules/launchd.py +++ b/plugins/modules/launchd.py @@ -514,7 +514,8 @@ def main(): result['status']['current_pid'] != result['status']['previous_pid']): result['changed'] = True if module.check_mode: - result['changed'] = True + if result['status']['current_state'] != action: + result['changed'] = True module.exit_json(**result)