Hi everyone,
Is it possible to provide a relative path to a file as attach parameter of the ansible mail module?
From
my tests and internet searches, it doesn't work: in my example, the
playbook calls the task that is in directory structure
./roles/notify/tasks/send_email.yml and the file I need to attach is in
./roles/notify/files.
Directory structure
./roles/notify/
- files: contains the file to send
- tasks: send_email.yml
Task "Send email":
name: Send email
mail:
host: "{{ hostvars[groups['smtp'][0]]['ansible_host'] }}"
from: "{{ from_address }}"
to: "{{ to_recipients }}"
cc: "{{ cc_recipients }}"
attach: "./files/{{ attached_file }}"
subject: "{{ subject }}"
body: "{{ body }}"
subtype: "html"
I also tried with those combinations but none works:
attach: "{{ attached_file }}"
attach: "./roles/notify/files/{{ attached_file }}"
Haven't I got any other option but copying the file to a temporary directory and provide an absolute path to it?
Many thanks for your help.
Best regards,
Sabrina