1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-16 04:47:30 +00:00

fix(launchd): restarted and reloaded always report changed in check mode too

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky 2026-05-31 11:53:52 +12:00
parent 7b764a84e2
commit 3b37d55146

View file

@ -501,23 +501,22 @@ def main():
# Run the requested task
if not module.check_mode:
state, pid, status_code, err = tasks[action].run()
# restarted and reloaded always perform commands unconditionally, so they always change state
if action in ("restarted", "reloaded"):
result["changed"] = True
result["status"]["current_state"] = ServiceState.to_string(state)
result["status"]["current_pid"] = pid
result["status"]["status_code"] = status_code
result["status"]["error"] = err
if (
# restarted and reloaded always perform commands unconditionally, so they always change state
if action in ("restarted", "reloaded"):
result["changed"] = True
elif (
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)