- name: Size is big
debug: msg: "too big size: {{ item}} " when: item > "20" with_items: "{{ test.results|map(attribute='stdout')|list}}"
vars: filesystems: - / - /tmp
size_too_big: "20"
tasks:
...
- name: Size is big v2 debug: msg: "{{ item.1 }} is too big! size={{ item.0 }} " when: item.0 > size_too_big with_together: - "{{ test.results|map(attribute='stdout')|list }}" - "{{ filesystems }}"
TASK [Size is big v2] **********************************************************ok: [demobox] => (item=[u'37', u'/']) => { "item": [ "37", "/" ], "msg": "/ is too big! size=37 "}ok: [demobox] => (item=[u'37', u'/tmp']) => { "item": [ "37", "/tmp" ], "msg": "/tmp is too big! size=37 "}
- name: Disk role.
include_role:
name: disk_role
vars:
mount_point: "{{ item }}"
with_items:
- "/dev"
- "/backup"
Hi,
I am tryig to write an Ansible script which will Generat Alert on Disk Usage. Once the Disk Usage goes above the Threshold, alert will be generated.
Below is start up code.
---- hosts: "{{ hostGroup }}"user: gamesrootbecome: truebecome_user: rootgather_facts: notasks:- shell: df -h "{{ item }}" | tail -n 1 | awk {'print $5 '} | sed 's/%//g'with_items:- /- /home- /backupregister: test
- debug:msg: "{{ test.results|map(attribute='stdout')|list }}"- name: Size is bigshell: echo "tobig size "when: test.results > 20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`