mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-16 04:47:30 +00:00
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. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(changelog): add fragment for PR 12122 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(launchd): restarted and reloaded always report changed in check mode too Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * consolidate if branches --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3fa258f5a8
commit
b12c21f0ce
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