Ansible: How to get service status by Ansible?

Question:

I want to get service like redis-server running status by Ansible.

I know how to use Ansible service module to stop or start system service. But how can I get the current service status?

Answer:

Use command module with service redis-server status and parse stdout.
Or use patched service module.

Leave a Reply