From 0421ade0df6abbafea26e6de31668d37187b5922 Mon Sep 17 00:00:00 2001 From: "Gunwoo Gim (a.k.a. Nicho1as)" Date: Tue, 25 Oct 2016 00:49:11 +0900 Subject: [PATCH] now you can use a network link name with a hyphen --- roles/ceph-common/templates/ceph.conf.j2 | 2 +- roles/ceph-common/templates/mon_addr_interface.j2 | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/ceph-common/templates/ceph.conf.j2 b/roles/ceph-common/templates/ceph.conf.j2 index a068392dc..4d72a0b8a 100644 --- a/roles/ceph-common/templates/ceph.conf.j2 +++ b/roles/ceph-common/templates/ceph.conf.j2 @@ -24,7 +24,7 @@ mon_initial_members = {% if groups[mon_group_name] is defined %}{% for host in g {% if monitor_address_block is defined %} mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_all_ipv4_addresses'] | ipaddr(monitor_address_block) | first }}{% if not loop.last %},{% endif %}{% endfor %} {% elif groups[mon_group_name] is defined %} -mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_' + monitor_interface]['ipv4']['address'] }}{% if not loop.last %},{% endif %}{% endfor %} +mon host = {% for host in groups[mon_group_name] %}{% for key in hostvars[host].iterkeys() %}{% if hostvars[host][key]['macaddress'] is defined and hostvars[host][key]['device'] is defined and hostvars[host][key]['device'] == monitor_interface %}{{ hostvars[host][key]['ipv4']['address'] }}{% endif %}{% endfor %}{% if not loop.last %},{% endif %}{% endfor %} {% elif (hostvars[host]['monitor_interface'] is defined and hostvars[host]['monitor_interface'] != "interface") or monitor_interface != "interface" %} {% include 'mon_addr_interface.j2' %} {% else %} diff --git a/roles/ceph-common/templates/mon_addr_interface.j2 b/roles/ceph-common/templates/mon_addr_interface.j2 index 91db00785..107483177 100644 --- a/roles/ceph-common/templates/mon_addr_interface.j2 +++ b/roles/ceph-common/templates/mon_addr_interface.j2 @@ -1 +1,7 @@ -mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }}{% if not loop.last %},{% endif %}{% endfor %} +mon host = {% for host in groups[mon_group_name] %} + {% for key in hostvars[host].iterkeys() %} + {% if hostvars[host][key]['macaddress'] is defined and hostvars[host][key]['device'] is defined and hostvars[host][key]['device'] == monitor_interface %} + {{ hostvars[host][key]['ipv4']['address'] }} + {% endif %} + {% endfor %} +{% if not loop.last %},{% endif %}{% endfor %}