更新时间:2023-11-26 18:12:52
下面会在service_stop
中注册模块输出;如果模块执行的标准输出不包含 "Could not find the requested service"
并且服务无法根据返回代码停止,则模块执行将失败.由于您没有包含整个堆栈跟踪,我假设您发布的错误在标准输出中,您可能需要根据您的错误稍作更改.
The following will register the module output in service_stop
; if the module execution's standard output does not contain "Could not find the requested service"
AND the service fails to stop based on return code, the module execution will fail. Since you did not include the entire stack trace I am assuming the error you posted is in the standard output, you may need to change slightly based on your error.
- name: Stop service
register: service_stop
failed_when:
- '"Could not find the requested service" not in service_stop.stdout'
- service_stop.rc != 0
service:
name: '{{ target_service }}'
state: stopped