ansible email and template

All,
I am trying to send email in html
I keep getting
TASK: [pre_install | send email] *************************************
fatal: [localhost → 127.0.0.1] => A variable inserted a new parameter into the module args. Be sure to quote variables if they contain equal signs (for example: “{{var}}”).

My commands

  • name: delete temp dir
    local_action: file path=./tmp state=absent

  • name: template create dir
    local_action: file path=./tmp state=directory

  • name: template email
    local_action: template src=…/files/email_template.j2 dest=./tmp/email.txt

  • name: send email
    local_action: mail
    host=‘smtp3.hp.com
    port=25
    subject=“EGIT IIB ENVIRONMENT SETUP”
    body=“{{ lookup(‘file’, ‘./tmp/email.txt’) }}”
    from="antoine.voiry@gmail.com"
    to="antoine.voiry@gmail.com"
    cc="antoine.voiry@gmail.com"
    headers=“Content-type=text/html”

The ./tmp/email.tx looks as follow

Dear All,
The environment SANDBOX will be built or re-buil t.
Kind Regards

The html content of your body contains quotes which break the quoting that you wrap it in.

Instead of:

body=“{{ lookup(‘file’, ‘./tmp/email.txt’) }}”

Try:

body=‘{{ lookup(“file”, “./tmp/email.txt”) }}’

Which is basically switching your surrounding quotes to ’ since your body uses " throughout.