From: Patrick Donnelly Date: Mon, 19 Sep 2016 21:35:41 +0000 (-0400) Subject: ceph.conf: add variable setting monitor addr block X-Git-Tag: v1.0.7~22^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bcb2e39017ca4e2b4cbb0a583a159e69aa76745d;p=ceph-ansible.git ceph.conf: add variable setting monitor addr block For some providers (such as upcoming Linode support), some NICs may have multiple IP addresses. (In the case of Linode, the only NIC has a public and private IP address.) This is normally okay as we can use the ceph.conf cluster_network and public_network variables to force the monitor to listen on the addresses we want. However, we also need ansible to set the correct monitor IP addresses in "mon hosts" (i.e. the addresses the monitors will listen on!). This new monitor_address_block setting tells ansible which IP address to use for each monitor. Signed-off-by: Patrick Donnelly --- diff --git a/roles/ceph-common/tasks/checks/check_mandatory_vars.yml b/roles/ceph-common/tasks/checks/check_mandatory_vars.yml index ed800d992..975049511 100644 --- a/roles/ceph-common/tasks/checks/check_mandatory_vars.yml +++ b/roles/ceph-common/tasks/checks/check_mandatory_vars.yml @@ -40,12 +40,13 @@ - osd_objectstore != 'bluestore' - osd_group_name in group_names -- name: make sure monitor_interface or monitor_address is configured +- name: make sure monitor_interface or monitor_address or monitor_address_block is configured fail: - msg: "monitor_interface or monitor_address must be configured. Interface for the monitor to listen on or IP address of that interface" + msg: "Either monitor_interface, monitor_address, or monitor_address_block must be configured. Interface for the monitor to listen on or IP address of that interface" when: - monitor_interface == 'interface' - monitor_address == '0.0.0.0' + - not monitor_address_block - mon_group_name in group_names - name: make sure cluster_network configured diff --git a/roles/ceph-common/templates/ceph.conf.j2 b/roles/ceph-common/templates/ceph.conf.j2 index f04f6d441..61bd2cf42 100644 --- a/roles/ceph-common/templates/ceph.conf.j2 +++ b/roles/ceph-common/templates/ceph.conf.j2 @@ -21,7 +21,9 @@ mon_initial_members = {% if groups[mon_group_name] is defined %}{% for host in g {% endif %} {% if not mon_containerized_deployment and not mon_containerized_deployment_with_kv %} -{% if groups[mon_group_name] is defined %} +{% 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 %} {% elif (hostvars[host]['monitor_interface'] is defined and hostvars[host]['monitor_interface'] != "interface") or monitor_interface != "interface" %} {% include 'mon_addr_interface.j2' %}