Ansible problem with command shell : mail

Hey !!

With prompt shell on my linux this command works perfectly :

mail -a “Content-Type: text/html” -s “Ansible deployment HospitalisV3” moi@outlook.com </home/ansible/test_hospi_package/frontoffice/roles/frontoffice/files/mail_content.html

But when i use this next task, there is error with ansible :

  • name: “Execut command shell with html”
    shell: mail -a “Content-Type: text/html” -s “Ansible deployment HospitalisV3” moi@outlook.com </home/ansible/test_hospi_package/frontoffice/roles/frontoffice/files/mail_content.html
    delegate_to: localhost

Error is that ansible not understand “Content-Type: text/html”

Someone can you help me please community Ansible !!! :slight_smile:

Best Regards,

Karther

Try using the native mail module instead of shell:
https://docs.ansible.com/ansible/latest/modules/mail_module.html

Thanks for your help Dick !! :slight_smile:

But i try this module mail and the module in documentation Ansible but it’s not works :
The error is :

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: socket.error: [Errno 101] Network is unreachable

It’s for that i use commande mail and not module of ansible …

Thanks for your help community ansible !! :slight_smile:

Regards,

Karther