diff --git a/roles/ceph-common/templates/ceph.conf.j2 b/roles/ceph-common/templates/ceph.conf.j2 index aa383c217..ebff7b59e 100644 --- a/roles/ceph-common/templates/ceph.conf.j2 +++ b/roles/ceph-common/templates/ceph.conf.j2 @@ -8,59 +8,62 @@ auth service required = none auth client required = none auth supported = none {% endif %} -{% if not mon_containerized_deployment_with_kv %} +{% if not mon_containerized_deployment_with_kv and not mon_containerized_deployment %} fsid = {{ fsid }} {% endif %} max open files = {{ max_open_files }} {% if common_single_host_mode is defined %} osd crush chooseleaf type = 0 {% endif %} -[client.libvirt] -admin socket = {{ rbd_client_admin_socket_path }}/$cluster-$type.$id.$pid.$cctid.asok # must be writable by QEMU and allowed by SELinux or AppArmor -log file = {{ rbd_client_log_file }} # must be writable by QEMU and allowed by SELinux or AppArmor +{# NOTE (leseb): the blank lines in-between are needed otherwise we won't get any line break #} +{% if groups[mon_group_name] is defined %} +mon_initial_members = {% if groups[mon_group_name] is defined %}{% for host in groups[mon_group_name] %}{% if hostvars[host]['ansible_fqdn'] is defined and mon_use_fqdn %}{{ hostvars[host]['ansible_fqdn'] }}{% if not loop.last %},{% endif %}{% elif hostvars[host]['ansible_hostname'] is defined %}{{ hostvars[host]['ansible_hostname'] }}{% if not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %} -[mon] -{% if not mon_containerized_deployment_with_kv %} -{% for host in groups[mon_group_name] %} -{% if hostvars[host]['ansible_fqdn'] is defined and mon_use_fqdn %} -[mon.{{ hostvars[host]['ansible_fqdn'] }}] -host = {{ hostvars[host]['ansible_fqdn'] }} -{% elif hostvars[host]['ansible_hostname'] is defined %} -[mon.{{ hostvars[host]['ansible_hostname'] }}] -host = {{ hostvars[host]['ansible_hostname'] }} -{% endif %} -# we need to check if monitor_interface is defined in the inventory per host or if it's set in a group_vars file -{% if mon_containerized_deployment %} -{% set interface = ["ansible_",ceph_mon_docker_interface]|join %} -{% if interface in hostvars[host] and 'ipv4' in hostvars[host][interface] %} -# user address from interface {{ ceph_mon_docker_interface }} -mon addr = {{ hostvars[host][interface]['ipv4']['address'] }} - {% elif hostvars[host]['monitor_address'] is defined %} - # use host monitor address -mon addr = {{ hostvars[host]['monitor_address'] }} - {% elif monitor_address != "0.0.0.0" %} - # use group_var monitor address -mon addr = monitor_address -{% endif %} +mon_host = {% if groups[mon_group_name] is defined %}{% for host in groups[mon_group_name] %}{{ hostvars[host]['ansible_' + monitor_interface]['ipv4']['address'] }}{% if not loop.last %},{% endif %}{% endfor %}{% endif %} {% 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' %} {% endif %} +{% if mon_containerized_deployment %} +fsid = {{ fsid }} +{% if groups[mon_group_name] is defined %} +{% for host in groups[mon_group_name] %} +{% if mon_containerized_deployment %} +{% set interface = ["ansible_",ceph_mon_docker_interface]|join %} +mon_host = {{ hostvars[host]['ansible_' + interface]['ipv4']['address'] }} +{% if not loop.last %},{% endif %} +{% elif hostvars[host]['monitor_address'] is defined %} +mon_host = {{ hostvars[host]['monitor_address'] }} +{% if not loop.last %},{% endif %} +{% elif monitor_address != "0.0.0.0" %} +mon_host = monitor_address +{% if not loop.last %},{% endif %} +{% endif %} {% endfor %} {% endif %} +{% endif %} + +{% if public_network is defined %} +public_network = {{ public_network }} +{% endif %} +{% if cluster_network is defined %} +cluster_network = {{ cluster_network }} +{% endif %} +max open files = {{ max_open_files }} +{% if common_single_host_mode is defined %} +osd crush chooseleaf type = 0 +{% endif %} + +[client.libvirt] +admin socket = {{ rbd_client_admin_socket_path }}/$cluster-$type.$id.$pid.$cctid.asok # must be writable by QEMU and allowed by SELinux or AppArmor +log file = {{ rbd_client_log_file }} # must be writable by QEMU and allowed by SELinux or AppArmor [osd] osd mkfs type = {{ osd_mkfs_type }} osd mkfs options xfs = {{ osd_mkfs_options_xfs }} osd mount options xfs = {{ osd_mount_options_xfs }} osd journal size = {{ journal_size }} -{% if cluster_network is defined %} -cluster_network = {{ cluster_network }} -{% endif %} -{% if public_network is defined %} -public_network = {{ public_network }} -{% endif %} {% if filestore_xattr_use_omap != None %} filestore xattr use omap = {{ filestore_xattr_use_omap }} {% elif osd_mkfs_type == "ext4" %} diff --git a/roles/ceph-common/templates/mon_addr_address.j2 b/roles/ceph-common/templates/mon_addr_address.j2 index 19dfa5312..0a6323594 100644 --- a/roles/ceph-common/templates/mon_addr_address.j2 +++ b/roles/ceph-common/templates/mon_addr_address.j2 @@ -1,2 +1 @@ -mon addr = {{ hostvars[host]['monitor_address'] if hostvars[host]['monitor_address'] is defined else monitor_address }} - +mon host = {% for host in groups[mon_group_name] %}{{ hostvars[host]['monitor_address'] if hostvars[host]['monitor_address'] is defined else monitor_address }}{% if not loop.last %},{% endif %}{% endfor %} diff --git a/roles/ceph-common/templates/mon_addr_interface.j2 b/roles/ceph-common/templates/mon_addr_interface.j2 index b5c85cd06..91db00785 100644 --- a/roles/ceph-common/templates/mon_addr_interface.j2 +++ b/roles/ceph-common/templates/mon_addr_interface.j2 @@ -1,2 +1 @@ -mon addr = {{ hostvars[host]['ansible_' + (hostvars[host]['monitor_interface'] if hostvars[host]['monitor_interface'] is defined else monitor_interface) ]['ipv4']['address'] }} - +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 %}