Kai,
Here is my actual playbook. This gives me the output in plain csv file 
format. To represent the output via email, please suggest the right 
approach.

---
> - name: Failure user accounts
>   gather_facts: no
>   hosts: 127.0.0.1
>
>   tasks:
>     - name: Create csv file
>       file:
>         dest: /tmp/file.csv
>         state: touch
>       delegate_to: 127.0.0.1
>
>     - include_vars: vars.yaml
>
>     - include_tasks: subtask.yaml
>       with_items: '{{ users }}'
>       
>     - name: Send the Failure user accounts on email
>       local_action: mail
>                     host= '127.0.0.1'
>                     port=25
>                     subject="Failure user accounts"
>                     body="{{ lookup('file', '/tmp/file.csv') }}"
>                     attach="file.csv"
>                     from="[email protected]"
>                     to="[email protected]"
>                     subtype="html"
>                     charset=utf8
>       delegate_to: 127.0.0.1
>       run_once: true
>
>     - Clear content file
>       file:
>         dest: /tmp/file.csv
>         state: absent
>       delegate_to: 127.0.0.1
>
>
>
On Monday, 27 August 2018 10:56:35 UTC-4, Kai Stian Olstad wrote:
>
> On Monday, 27 August 2018 13.40.48 CEST Saravanan wrote: 
> > All, 
> > In the below Ansible email task, instead of attaching the csv file to 
> the 
> > email, need to send the contend of csv file in the body of the email as 
> > html table. 
>
> I'm not sure what you are trying too achieve but you should probably check 
> at ARA https://github.com/openstack/ara 
>
>
> > 
> >    - name: Send the SSH status to email 
> >       local_action: mail 
> >                     host= '127.0.0.1' 
> >                     port=25 
> >                     subject="SSH Connection status for Unix sudo 
> accounts" 
> >                     body="SSH Failure Service accounts" 
> >                     attach="/tmp/content.csv" 
> >                     from="[email protected] <javascript:>" 
> >                     to="[email protected] <javascript:> <
> [email protected] <javascript:>>" 
> >                     subtype="html" 
> >                     charset=utf8 
> >       delegate_to: 127.0.0.1 
> >       run_once: true 
>
> What you are trying to do is possible but you need to go through a lot of 
> hoops, choosing csv is making this harder that is could be, yaml or json 
> would have been easier. 
>
> As is, you would need to create the csv file to a list of list, then use 
> template to create the html table. 
>
>
> -- 
> Kai Stian Olstad 
>
>
>

-- 
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/a525c4b1-674d-478b-bfd3-d95bce058498%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to