On Mon, 16 Dec 2019 13:01:18 -0800 (PST)
evnflow <
vincent...@gmail.com> 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:
ans...@master.example.com
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