how to do this logic.
run first task on all 4 servers in inventory and register in ls_file Then using 2nd task send a SINGLE mail to user with the contents of ls_file
- name: check file
shell: ls -l /var/abcd.txt
register: ls_file
- name: send mail to user
mail:
host: relay.server
port: 25
from: abcd@company.com
to: manager <manager@company.com>
subject: file availability
mail body should be as below.
server1 - -rw-------. 1 root root 4405 Apr 20 2020 /var/abcd.txt
server2 - -rw-------. 1 root root 4405 Apr 12 2020 /var/abcd.txt
server3 - -rw-------. 1 root root 4405 Mar 15 2020 /var/abcd.txt
server4 - -rw-------. 1 root root 4405 Apr 19 2020 /var/abcd.txt