I'm trying to come up a way to iterate through ansible_mounts and, if one 
of the mounts is over 80% used, add that to a list that i can print out 
later and possibly email it.  Here's what I have so far:

---
- hosts: localhost
  gather_facts: no
  become: yes
  become_method: sudo

  pre_tasks:
    - setup:
        filter: 'ansible_mounts'

  tasks:

   - name: Show the mounts and disk usage
     debug:
       msg: "Disk usage: {{ item.mount }} is {{ (100 * ((item.size_total - 
item.size_available)/item.size_total))| float | round(1, 'common') }}%"
     when: "(100 * ((item.size_total - 
item.size_available)/item.size_total)) > 80"
     with_items:
       - "{{ ansible_mounts }}"
     loop_control:
       label: "{{ item.mount }}"

This works, but I'm not sure how to add it to a list.  I'm doing this on 
localhost for how to get the idea solid, then I should be able to run it on 
other hosts.  Any ideas on how to accomplish this?

Thanks,
Harry

-- 
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/ddef7136-4919-4082-a7e9-f4a6e1fb9751%40googlegroups.com.

Reply via email to