]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
fixes monitor_address and monitor_interface features
authorAndrew Schoen <aschoen@redhat.com>
Wed, 2 Nov 2016 17:53:32 +0000 (12:53 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Wed, 2 Nov 2016 20:27:12 +0000 (15:27 -0500)
Before this commit if you had set monitor_interface in your
inventory file for a specific host it would be ignored and the value
in group_vars/all would have been used.

Also, this enables support for monitor_address again as it had been
broken by previous changes to this template.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
roles/ceph-common/templates/ceph.conf.j2

index 4d72a0b8ab704ac5a6b551458f0a38fdab3cd947..fbbb4d87d4b057a82dee8957983d3ccd144f2f75 100644 (file)
@@ -24,11 +24,20 @@ 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] %}{% 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 %}
-{% include 'mon_addr_address.j2' %}
+mon host = {% for host in groups[mon_group_name] %}
+             {% set address = hostvars[host]['monitor_address'] if hostvars[host]['monitor_address'] is defined else monitor_address %}
+             {% set interface = hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface %}
+             {% if address != "0.0.0.0" -%}
+               {{ address }}
+             {%- else %}
+               {% 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'] == interface -%}
+                    {{ hostvars[host][key]['ipv4']['address'] }}
+                 {%- endif %}
+               {% endfor %}
+             {% endif %}
+             {%- if not loop.last %},{% endif %}
+           {% endfor %}
 {% endif %}
 {% endif %}
 {% if mon_containerized_deployment %}