From 02ba65dbbe564d3080aab361922d5d863f7f2b1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Tue, 12 Sep 2017 16:28:08 -0600 Subject: [PATCH] mon: add support for monitor_address block for containers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Han --- roles/ceph-mon/templates/ceph-mon.service.j2 | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/roles/ceph-mon/templates/ceph-mon.service.j2 b/roles/ceph-mon/templates/ceph-mon.service.j2 index 490d5973c..dc2169a5f 100644 --- a/roles/ceph-mon/templates/ceph-mon.service.j2 +++ b/roles/ceph-mon/templates/ceph-mon.service.j2 @@ -29,17 +29,27 @@ ExecStart=/usr/bin/docker run --rm --name ceph-mon-%i --net=host \ --net=host \ {% endif -%} -e IP_VERSION={{ ip_version[-1:] }} \ - {% if monitor_address is defined and monitor_address != '0.0.0.0' %} + {% if monitor_address_block | length > 0 %} {% if ip_version == 'ipv4' -%} - -e MON_IP={{ monitor_address }} \ + -e MON_IP={{ hostvars[inventory_hostname]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }} \ {% elif ip_version == 'ipv6' -%} - -e MON_IP=[{{ monitor_address }}] \ + -e MON_IP=[{{ hostvars[inventory_hostname]['ansible_all_' + ip_version + '_addresses'] | ipaddr(monitor_address_block) | first }}] \ {% endif -%} - {% elif ip_version == 'ipv4' -%} - -e MON_IP={{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version]['address'] }} \ - {% elif ip_version =='ipv6' -%} - -e MON_IP=[{{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version][0]['address'] }}] \ + {% elif hostvars[inventory_hostname]['monitor_address'] is defined and hostvars[inventory_hostname]['monitor_address'] != '0.0.0.0' -%} + {% if ip_version == 'ipv4' -%} + -e MON_IP={{ hostvars[inventory_hostname]['monitor_address'] }} \ + {% elif ip_version == 'ipv6' -%} + -e MON_IP=[{{ hostvars[inventory_hostname]['monitor_address'] }}] \ + {% endif -%} + {% else -%} + {% set interface = ["ansible_",monitor_interface]|join %} + {% if ip_version == 'ipv6' -%} + -e MON_IP=[{{ hostvars[inventory_hostname][interface][ip_version][0]['address'] }}] \ + {% elif ip_version == 'ipv4' -%} + -e MON_IP={{ hostvars[inventory_hostname][interface][ip_version]['address'] }} \ + {% endif -%} {% endif -%} + -e CLUSTER={{ cluster }} \ -e FSID={{ fsid }} \ -e CEPH_PUBLIC_NETWORK={{ public_network }} \ -- 2.39.5