---
- name: This playbook is for Testing Disk Space
hosts: proxy
become: yes
become_method: sudo
serial: 1
any_errors_fatal: true
ignore_errors: yes
gather_facts: yes
vars:
ansible_paython_interpreter: /usr/bin/python
tasks:
- name: disk usage from command module
shell: df -h / | tail -n 1 | awk '{ print $5 }'
register: used_space
- debug:
var: used_space.stdout
register: one
- name: decision making weather to proceed with update the system or not
fail: msg="{{ inventory_hostname }} have low disk space. Please Make some space then run the updates."
when: used_space.stdout >= "70%"
ignore_errors: no
- name: update the system
yum:
name: "*"
state: latest
exclude: 'kernel*'
update_cache: yes
update_only: yes
register: yum_update
- debug:
msg: "{{ yum_update }}"
******************************
In the example if disk space is used by 75% then task stops playing but in this case i want to set email notification send to me so how can i do that ??