Thanks that worked!  Only issue is now that it is sending an email with the 
status of all the mounts one at a time. Is there anyway I can limit email 
to the on mount that actually hits the threshold? 

On Monday, December 16, 2019 at 4:30:25 PM UTC-5, Vladimir Botka wrote:
>
> On Mon, 16 Dec 2019 13:01:18 -0800 (PST) 
> evnflow <[email protected] <javascript:>> wrote: 
>
> > Is there a way you can send a mail with-in assert when 
>  any_errors_fatal: 
> > true ? 
> > 
> > - name: Assert that the disk limit ({{ disk_limit }}) has not exceeded 
> >   assert: 
> >     that: ( (disk_usage|float)/mount.size_total ) < disk_limit|float 
> >     msg: "Disk usage {{ disk_usage_ratio_s }} exceeds {{ 
> disk_limit_ratio_s 
> > }}" 
> >   any_errors_fatal: true 
>
> FWIW. Conditionally send the email and end the host. For example 
>
>   - block: 
>       - mail: 
>           subject: Ansible disk usage report 
>           to: [email protected] <javascript:> 
>           body: | 
>             Disk usage {{ disk_usage_ratio_s }} 
>             exceeds {{ disk_limit_ratio_s }} 
>       - meta: end_host 
>     when: ((disk_usage|float)/mount.size_total) > disk_limit|float 
>
> Cheers, 
>
>         -vlado 
>

-- 
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/971a6f17-9e90-4893-a367-9023dbbd52f2%40googlegroups.com.

Reply via email to