Deep R Gill:
Hi friends, I am new ansible user and need help with playbook:
- first task checks the status of service and register the result
- second task will log the status in a file if service is down. result.stdout.find(‘inactive’) != -1
name: check status of a service and email if it's up/down
hosts: test-node01
tasks:
- command: sudo systemctl status apache2
register: result
- name: Log service status
shell: echo "service is down" > /home/cdeepak/os_service_status.txt
when: result.stdout.find('inactive') != -1
Please help, thank you