mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-14 03:55:37 +00:00
[PR #12122/b12c21f0 backport][stable-13] launchd: fix restarted and reloaded always reporting changed=False (#12247)
launchd: fix `restarted` and `reloaded` always reporting `changed=False` (#12122)
* fix(launchd): restarted and reloaded always report changed
Both actions unconditionally execute commands (unload/load/start),
so changed must always be True in non-check mode, regardless of
whether the PID or state happened to match before and after.
* feat(changelog): add fragment for PR 12122
* fix(launchd): restarted and reloaded always report changed in check mode too
* consolidate if branches
---------
(cherry picked from commit b12c21f0ce)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3bc92d03c4
commit
a4cac6f833
2 changed files with 9 additions and 4 deletions
|
|
@ -0,0 +1,4 @@
|
|||
bugfixes:
|
||||
- "launchd - fix ``restarted`` and ``reloaded`` states always reporting ``changed=False``
|
||||
(https://github.com/ansible-collections/community.general/issues/6199,
|
||||
https://github.com/ansible-collections/community.general/pull/12122)."
|
||||
|
|
@ -507,14 +507,15 @@ def main():
|
|||
result["status"]["status_code"] = status_code
|
||||
result["status"]["error"] = err
|
||||
|
||||
# restarted and reloaded always perform commands unconditionally, so they always change state
|
||||
if (
|
||||
result["status"]["current_state"] != result["status"]["previous_state"]
|
||||
action in ("restarted", "reloaded")
|
||||
or result["status"]["current_state"] != result["status"]["previous_state"]
|
||||
or result["status"]["current_pid"] != result["status"]["previous_pid"]
|
||||
):
|
||||
result["changed"] = True
|
||||
if module.check_mode:
|
||||
if result["status"]["current_state"] != action:
|
||||
result["changed"] = True
|
||||
elif module.check_mode and result["status"]["current_state"] != action:
|
||||
result["changed"] = True
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue