From 97cf08e89729db35264d0fb2c55ac01941761b9d Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 9 Aug 2018 11:03:32 +0200 Subject: [PATCH] config: ensure rgw section has the correct name the ceph.conf.j2 always assumes the hostname used to register the radosgw in the servicemap is equivalent to `{{ ansible_hostname }}` which returns the shortname form. We need to detect which form of the hostname was used in case of already deployed cluster and update the ceph.conf accordingly. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1580408 Signed-off-by: Guillaume Abrioux (cherry picked from commit f422efb1d6b56ce56a7d39a21736a471e4ed357c) --- roles/ceph-config/templates/ceph.conf.j2 | 17 +++++++--------- roles/ceph-defaults/tasks/facts.yml | 25 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/roles/ceph-config/templates/ceph.conf.j2 b/roles/ceph-config/templates/ceph.conf.j2 index 03fae5a51..75f9c58b6 100644 --- a/roles/ceph-config/templates/ceph.conf.j2 +++ b/roles/ceph-config/templates/ceph.conf.j2 @@ -173,10 +173,10 @@ host = {{ hostvars[host]['ansible_hostname'] }} {% if rgw_group_name in group_names %} {% if inventory_hostname in groups.get(rgw_group_name, []) %} {% for host in groups[rgw_group_name] %} -{% if hostvars[host]['ansible_hostname'] is defined %} -[client.rgw.{{ hostvars[host]['ansible_hostname'] }}] -host = {{ hostvars[host]['ansible_hostname'] }} -keyring = /var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ hostvars[host]['ansible_hostname'] }}/keyring +{# {{ hostvars[host]['rgw_hostname'] }} for backward compatibility, fqdn issues. See bz1580408 #} +[client.rgw.{{ hostvars[host]['rgw_hostname'] }}] +host = {{ hostvars[host]['rgw_hostname'] }} +keyring = /var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ hostvars[host]['rgw_hostname'] }}/keyring log file = /var/log/ceph/{{ cluster }}-rgw-{{ hostvars[host]['ansible_hostname'] }}.log {% if hostvars[host]['radosgw_address_block'] is defined and hostvars[host]['radosgw_address_block'] != 'subnet' %} {% if ip_version == 'ipv4' %} @@ -217,7 +217,6 @@ rgw frontends = {{ radosgw_frontend_type }} {{ 'port' if radosgw_frontend_type = rgw frontends = {{ radosgw_frontend_type }} {{ 'port' if radosgw_frontend_type == 'civetweb' else 'endpoint' }}=[{{ hostvars[host][interface][ip_version][0]['address'] }}]:{{ radosgw_frontend_port }} {{ radosgw_frontend_options }} {% endif %} {% endif %} -{% endif %} {% endfor %} {% endif %} {% endif %} @@ -228,13 +227,11 @@ rgw frontends = {{ radosgw_frontend_type }} {{ 'port' if radosgw_frontend_type = {% if inventory_hostname in groups.get(nfs_group_name, []) and inventory_hostname not in groups.get(rgw_group_name, []) %} {% for host in groups[nfs_group_name] %} {% if nfs_obj_gw %} -{% if hostvars[host]['ansible_hostname'] is defined %} -[client.rgw.{{ hostvars[host]['ansible_hostname'] }}] -host = {{ hostvars[host]['ansible_hostname'] }} -keyring = /var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ hostvars[host]['ansible_hostname'] }}/keyring +[client.rgw.{{ hostvars[host]['rgw_hostname'] }}] +host = {{ hostvars[host]['rgw_hostname'] }} +keyring = /var/lib/ceph/radosgw/{{ cluster }}-rgw.{{ hostvars[host]['rgw_hostname'] }}/keyring log file = /var/log/ceph/{{ cluster }}-rgw-{{ hostvars[host]['ansible_hostname'] }}.log {% endif %} -{% endif %} {% endfor %} {% endif %} {% endif %} diff --git a/roles/ceph-defaults/tasks/facts.yml b/roles/ceph-defaults/tasks/facts.yml index eb927bcb4..c49264589 100644 --- a/roles/ceph-defaults/tasks/facts.yml +++ b/roles/ceph-defaults/tasks/facts.yml @@ -214,3 +214,28 @@ when: - containerized_deployment - ceph_docker_image | search("rhceph") + +- block: + - name: get current cluster status (if already running) + command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} -s -f json" + register: ceph_current_status + + - name: set_fact ceph_current_status (convert to json) + set_fact: + ceph_current_status: "{{ ceph_current_status.stdout | from_json }}" + + - name: set_fact rgw_hostname + set_fact: + rgw_hostname: "{% for key in ceph_current_status['servicemap']['services']['rgw']['daemons'].keys() %}{% if key == ansible_fqdn %}{{ key }}{% endif %}{% endfor %}" + when: + - ceph_current_fsid.get('rc', 1) == 0 + - inventory_hostname in groups.get(rgw_group_name, []) + # no servicemap before luminous + - ceph_release_num[ceph_release] >= ceph_release_num['luminous'] + - ansible_hostname != ansible_fqdn + +- name: set_fact rgw_hostname + set_fact: + rgw_hostname: "{{ ansible_hostname }}" + when: + - rgw_hostname is undefined \ No newline at end of file