On Thu, 5 Sep 2019 at 12:11, Rakesh Parida <[email protected]> wrote:
>
> I have a code as below and i have my html files present in /tmp/sanity/ .
> but i am getting error as "Failed to send mail: can't attach file" i get file
> not found
Well that's pretty clear: the file is not found.
Debug what is in list_html_files.stdout_lines[0] and adjust that.
Without any further information it's hard to tell.
On a related note, instead of fragile shell find/tr/xargs/sort , I
would strongly suggest to use the 'find' module.
That will at least return a standard data structure (which is easier
to offer help with).
Dick
> - name: list html files
> run_once: true
> local_action: shell find /tmp/sanity/ -type f -regex ".*.html" | tr -s
> '\n' ' ' | xargs | sort
> register: list_html_files
> - debug: msg="{{ list_html_files }}"
>
> - name: generate final email body
> run_once: true
> local_action: shell for i in `find /tmp/sanity/ -type f -regex
> ".*email.*.txt" | sort`; do cat $i ;done
> register: email_body
> - debug: msg="{{email_body}}"
>
> - name: email results
> become: true
> ignore_errors: true
> run_once: true
> mail:
> host: "{{smtp_host}}"
> port: 25
> subject: "raka"
> body: '{{ email_body.stdout }}'
> from: xxxxxxx
> to: "{{ email | default('xxxxxx') }}"
> attach:
> - '{{ list_html_files.stdout_lines[0] }}'
> charset: utf8
> delegate_to: localhost
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/69c639e2-ce8f-4931-90f4-bdb3ee0c00b5%40googlegroups.com.
--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAL8fbwP2kZX9OUGm%2BFFY8FyK2D%3D5RpG5y6JkXpkctheUVmPMqg%40mail.gmail.com.