]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
config: ensure rgw section has the correct name
authorGuillaume Abrioux <gabrioux@redhat.com>
Thu, 9 Aug 2018 09:03:32 +0000 (11:03 +0200)
committerSébastien Han <seb@redhat.com>
Mon, 13 Aug 2018 16:55:06 +0000 (18:55 +0200)
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 <gabrioux@redhat.com>
(cherry picked from commit f422efb1d6b56ce56a7d39a21736a471e4ed357c)

roles/ceph-config/templates/ceph.conf.j2
roles/ceph-defaults/tasks/facts.yml

index 03fae5a51b44bf2da60d1e5c309a7c750edce5dd..75f9c58b601de85debb325c669d4870a8829393f 100644 (file)
@@ -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 %}
index eb927bcb4213bf6c95994d9ee7833917cd6153a1..c49264589ce442bb6c2d51b5747360a0a4ec8a2d 100644 (file)
   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