I am trying to check if a given mount point exists for each host in my 
playbook. I am trying to generate a kind of report by printing Success or 
Failed using if-else, loops and flags (need something better than flags) 
inside a jinja2 template. First i am looping through all hosts and for each 
host i am looping through each ansible_mount and checking for a matching, 
setting a flag:

##Check if drive exists and have enough free space
{% for i in play_hosts %}
{% set foundDIR = false %}
{% for mountInfo in ansible_mounts %}
{% if DIR == mountInfo.mount %}
{% set foundDIR = true %}
{% if mountInfo.size_available > size %}
{{i}}: Success 
{% else %}
{{i}}: Failed 
{% endif %}
{% endif %}
{% endfor %}
{% if foundDIR == false %}
{{i}}: Failed - Mount dir {{DIR}} not found
{% endif %}

{% endfor %}

The problem is that i do not think this flag is properly as i always see 
the line -  Failed - Mount dir {{DIR}} not found
I am not sure what i am doing wrong here. Is this a syntax problem or this 
is never going to work ? If it is the latter, then what should i do to 
achieve this ?

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d74927aa-64e8-49ba-929d-70508ca1866c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to