I have multiple files in a path and it contains mail id of the users.
I need to loop the file content using with_items and filter users ID from the file content.
That ID’s should be passed into mail module, mail needs to be sent to those user ID’s.
Please help me filter only ID form the file content and it needs to be looped into mail module.
cat /test/user1
Name: Anton
ID: anton.s@xxx.com
cat /test/user2
Name: Jeniffer
ID: jennifer.m@xxx.com
-
shell: cat {{ item }} | egrep -v ‘provided|valid’
register: file_content
with_items: -
/test/user1
-
/test/user2
-
name: Send mail notification to the user
mail:
host: mailrelay.xxx.com
port: 25
body: “{{ lookup(‘file’, ‘{{ req_path }}/{{ req }}’) + lookup(‘file’, ‘{{ mail_sign }}’) }}”
charset: utf8
run_once: true