I wrote an ad-hoc command for checking NGINX status and found that its status is active (since the ActiveState value is active).
Now, I would like to know how we can achieve the same from an Ansible playbook.
I just want to know whether my NGINX is active or not, apache is active or not, from an Ansible playbook.
Adhoc cmd:
ansible -b webserver -m service -a "name=nginx"
ip-172-31-34-68.ap-south-1.compute.internal | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"name": "nginx",
"status": {
"ActiveEnterTimestamp": "Thu 2021-03-18 18:00:55 UTC",
"ActiveEnterTimestampMonotonic": "14598079",
"ActiveExitTimestampMonotonic": "0",
"ActiveState": "active",
"After": "tmp.mount sysinit.target basic.target -.mount systemd-tmpfiles-setup.service network.target remote-fs.target systemd-journald.socket nss-lookup.target system.slice"
}
}