Last active
August 29, 2015 14:24
-
-
Save halberom/72b70a8cba934b9d58b9 to your computer and use it in GitHub Desktop.
ansible - example of lookup to handle addresses for gluster cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: gluster_servers | |
vars: | |
rhel7_interface: enp0s3 | |
default_interface: eth0 | |
tasks: | |
- set_fact: | |
other_servers: "{{ lookup('template', 'lookup.j2') | from_yaml }}" | |
- debug: | |
msg: "addresses to use: {{ other_servers | join(',') }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment