From 8cf67e9a8747fd5c37dec9215e7c21480fb8ee95 Mon Sep 17 00:00:00 2001
From: "wu.chunyang" <wu.chunyang@99cloud.net>
Date: Thu, 26 Apr 2018 23:39:08 +0800
Subject: [PATCH] Fix the ceph-mgr connect to cluster failed

For luminous, the ceph_mgr service provide the
dashborad for ceph, and it need connect to cluster,
but now it failed to connect ceph cluster due to
ceph.client.admin.keyring missing, this ps to fix it.

Co-Authored-By: chenqiaomin <chen.qiaomin@99cloud.net>
Closes-Bug: #1768462

Change-Id: Idb24661bc5674780db390220ca02e22975490663
---
 ansible/roles/ceph/tasks/distribute_keyrings.yml | 11 +++++++++++
 ansible/roles/ceph/templates/ceph-mgr.json.j2    |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/ansible/roles/ceph/tasks/distribute_keyrings.yml b/ansible/roles/ceph/tasks/distribute_keyrings.yml
index f4aa389792..2f5f4158cd 100644
--- a/ansible/roles/ceph/tasks/distribute_keyrings.yml
+++ b/ansible/roles/ceph/tasks/distribute_keyrings.yml
@@ -36,6 +36,17 @@
     - "{{ ceph_files['ceph.monmap'] }}"
   when: inventory_hostname in groups['ceph-mon']
 
+- name: Pushing Ceph keyrings for Mgrs
+  become: true
+  bslurp:
+    src: "{{ item.content }}"
+    dest: "{{ node_config_directory }}/ceph-mgr/{{ item.filename }}"
+    sha1: "{{ item.sha1 }}"
+    mode: 0600
+  with_items:
+    - "{{ ceph_files['ceph.client.admin.keyring'] }}"
+  when: inventory_hostname in groups['ceph-mgr']
+
 - name: Pushing Ceph keyrings for RGWs
   become: true
   bslurp:
diff --git a/ansible/roles/ceph/templates/ceph-mgr.json.j2 b/ansible/roles/ceph/templates/ceph-mgr.json.j2
index e741fa8ba6..75c3885f85 100644
--- a/ansible/roles/ceph/templates/ceph-mgr.json.j2
+++ b/ansible/roles/ceph/templates/ceph-mgr.json.j2
@@ -12,6 +12,12 @@
             "dest": "/var/lib/ceph/mgr/ceph-{{ inventory_hostname }}/keyring",
             "owner": "ceph",
             "perm": "0600"
+        },
+        {
+            "source": "{{ container_config_directory }}/ceph.client.admin.keyring",
+            "dest": "/etc/ceph/ceph.client.admin.keyring",
+            "owner": "ceph",
+            "perm": "0600"
         }
     ]
 }