As you probably know on systemd if a service fails to start, you get an error code but not output. You have to call systemctl status foobar.service
in order to get the output from that service.
I want to build an ansible tasks that displays the errors and fails when needed. Just failing without information is not useful.
Here is my current implementation, which I do not like, as it is make out of too many tasks, hard to read and I do want to be able to re-use it much easier.
- command: systemctl reload foobar.service
register: result
ignore_errors: True
- debug: result
when: result.rc != 0
- command: systemctl status foobar.service
register: result2
when: result.rc != 0
- debug: var=result2
when: result.rc != 0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.