I've got a awk output
- name: read files
shell: awk -F "|" 'FNR==NR {lines[$1]=$2; next} $9 in lines {print lines[$9], "on", $2}' file1 file2
register: resultawk
- debug:
msg: "{{ resultawk.stdout.split('\n') }}"
this prints the output nicely with the line breaks
TASK [debug] **************************************************************************************** ok: [localhost] => { "msg": [ "field2file1 on field2file2", "field2file1 on field2file2" ] }
now, when i try sending the same message over mail
- name: send mail
mail:
subject: Report for {{ ansible_hostname }}
body:
msg: "{{ resultawk.stdout.split('\n') }}"
to:
- John Doe <xyz@xyz.com>
i get the following message
TASK [send mail] ********************************************************************* [WARNING]: The value {'msg': ['field2file1 on field2file2', 'field2file1 on field2file2']}" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change. ok: [localhost]
is there anyway to send the result over mail with the proper line breaks?