I have a playbook that uses gather facts, then I use the ansible_mounts 
fact in a jinja2 template.  In this template, I can print out each 
partition, the total size and total available.  What I'd like to do is to 
also calculate the percentage of space available.  I'm trying below, but 
keep getting a templating error when the playbook runs.  Any ideas?

server_mounts.html.j2
<html>
<body>
Partition/Mount Space Report

{{ now(false, '%m/%d/%Y %I:%M:%S') }}

---

{% for i in play_hosts | sort %}
Host: {{ i }}

{% for m in hostvars[i]['ansible_mounts'] %}
Partition: {{ m.mount }}
Total Space: {{ m.size_total|human_readable(unit="G") }}
Available Space: {{ m.size_available|human_readable(unit="G" }}
{% if m.size_total|int != 0 %}
Space used: {{ 100 * ((m.size_total - m.size.available/m.size_available)) 
|round(1, 'common') }}
{% endif %}
{% endfor %}
---------------------------------------
{% endfor %}
</body>
</html>

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/f2ce821e-98c6-4ae8-97bc-032580358ad6n%40googlegroups.com.

Reply via email to