{% macro loop_hosts(group) -%} {% for h in groups[group] -%} {% set h = dict(hostvars[h]) %} {{ caller(h) }} {%- endfor %} {%- endmacro %} {% macro loop_valid_hosts(group) -%} {% for h in groups[group] -%} {% set h = dict(hostvars[h]) %} {% if h.__ip.external is defined and h.__ip.internal is defined -%} {{ caller(h) }} {%- endif %} {%- endfor %} {%- endmacro %}