Ok, I found my mistake  !

I was reading the documentation for Ansible v2.3 
<https://docs.ansible.com/ansible/2.3/mail_module.html> which states that 
attach is:

A space-separated list of pathnames of files to attach to the message.
>

And I'm using Ansible v2.5 where attach is a classic list...

Using a list is working well.

Sorry for the noise


Le mercredi 12 septembre 2018 16:54:57 UTC+2, Matthieu Nantern a écrit :
>
> Hi All !
>
> I'm trying to attach multiple file to an email by using the mail module 
> <https://docs.ansible.com/ansible/2.4/mail_module.html> but it's not 
> working at all because I have parameters in my files' name:
>
> - name: send an email
>   mail:
>     host: email-smtp.eu-west-1.amazonaws.com
>     port: 587
>     username: xxx
>     password: xxx
>     from: xxx
>     to: "{{ item.firstname }} {{ item.lastname }} <{{ item.email }}>"
>     subject: configuration files
>     body: "{{ lookup('template', 'email_body.j2') }}"
>     secure: starttls
>     attach: "/mnt/data/users_config/{{ item.firstname }}_{{ item.lastname 
> }}.txt /mnt/data/users_config/{{ item.firstname }}_{{ item.lastname }}.pdf"
>   loop: "{{ users }}"
>
>
> I tried to add quotes almost everywhere but either it tries to load a single 
> file (not splitting by space) resulting in a [Errno 2] No such file or 
> directory or it ends up with an invalid yaml if I don't have the required 
> quotes.
>
> Any idea ?
>
> Thank you !
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fb03abd6-86dd-4979-8a7e-abe8ec1afdfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to