I have a requirement to collect all my service running status on multiple hosts and get it in one output file.
- name: To check status of services running
hosts: all
tasks:- name: “Check backup service”
shell:|
if ps -ef | grep ‘netbackup’ | grep =v grep > /dev/null; then
echo ‘ backup service running’
else
echo ‘ backup service not running’
fi
ignore_errors: false
register: ps_cmd
- name: “Check backup service”
above playbook i want to run on multiple hosts and collect output in one single file.
New contributor
Digvijay singh chouhan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1