Skip to content

Instantly share code, notes, and snippets.

@halberom
halberom / lookup.j2
Last active August 29, 2015 14:24
ansible - example of lookup to handle addresses for gluster cluster
{% for host in groups['gluster_servers'] %}
{% if host != inventory_hostname %}
{% if 'ansible_' + rhel7_interface in hostvars[host] %}
- {{ hostvars[host]['ansible_' + rhel7_interface]['ipv4']['address'] }}
{% else %}
- {{ hostvars[host]['ansible_' + default_interface]['ipv4']['address'] }}
{% endif %}
{% endif %}
{% endfor %}