From d35f9a4b706f10bfc1add7fa36dad2b334348afb Mon Sep 17 00:00:00 2001
From: "wu.chunyang" <wu.chunyang@99cloud.net>
Date: Sun, 13 Jan 2019 21:51:32 +0800
Subject: [PATCH] repair ceph_nfs container start failed

when enable ceph_nfs,it deploy failed, because no ganesha config
file, and the 'ganesha.nfs' command need root privilege to run.
i will modify ceph_nfs dockerfile,please review. thanks

https://review.openstack.org/#/c/630510/

Change-Id: I347107bc33733061ad043bffe38ecc1d16770afc
Closes-Bug: #1811581
---
 ansible/roles/ceph/tasks/config.yml              | 13 +++++++++++++
 ansible/roles/ceph/tasks/distribute_keyrings.yml | 13 +++++++++++++
 ansible/roles/ceph/templates/ceph-nfs.json.j2    |  2 +-
 ansible/roles/ceph/templates/ganesha.conf.j2     |  1 -
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/ansible/roles/ceph/tasks/config.yml b/ansible/roles/ceph/tasks/config.yml
index 470302c5ee..ccd9185bb6 100644
--- a/ansible/roles/ceph/tasks/config.yml
+++ b/ansible/roles/ceph/tasks/config.yml
@@ -55,3 +55,16 @@
     - "ceph-mgr"
     - "ceph-mds"
     - "ceph-nfs"
+
+- name: Copying over ganesha.conf for ceph-nfs
+  template:
+    src: "{{ item }}"
+    dest: "{{ node_config_directory }}/ceph-nfs/ganesha.conf"
+    mode: 0600
+  become: true
+  when:
+    - inventory_hostname in groups['ceph-nfs']
+  with_first_found:
+    - "{{ node_custom_config }}/ganesha.conf"
+    - "{{ node_custom_config }}/ceph-nfs/ganesha.conf"
+    - "ganesha.conf.j2"
diff --git a/ansible/roles/ceph/tasks/distribute_keyrings.yml b/ansible/roles/ceph/tasks/distribute_keyrings.yml
index 2f5f4158cd..bb391f1c87 100644
--- a/ansible/roles/ceph/tasks/distribute_keyrings.yml
+++ b/ansible/roles/ceph/tasks/distribute_keyrings.yml
@@ -58,3 +58,16 @@
     - "{{ ceph_files['ceph.client.admin.keyring'] }}"
     - "{{ ceph_files['ceph.client.radosgw.keyring'] }}"
   when: inventory_hostname in groups['ceph-rgw']
+
+- name: Pushing Ceph keyrings for NFSs
+  become: true
+  bslurp:
+    src: "{{ item.content }}"
+    dest: "{{ node_config_directory }}/ceph-nfs/{{ item.filename }}"
+    sha1: "{{ item.sha1 }}"
+    mode: 0600
+  with_items:
+    - "{{ ceph_files['ceph.client.admin.keyring'] }}"
+  when:
+    - inventory_hostname in groups['ceph-nfs']
+    - enable_ceph_nfs | bool
diff --git a/ansible/roles/ceph/templates/ceph-nfs.json.j2 b/ansible/roles/ceph/templates/ceph-nfs.json.j2
index 05d88924fc..45b75d7402 100644
--- a/ansible/roles/ceph/templates/ceph-nfs.json.j2
+++ b/ansible/roles/ceph/templates/ceph-nfs.json.j2
@@ -1,5 +1,5 @@
 {
-    "command": "/usr/bin/ganesha.nfsd -f /etc/ganesha/ganesha.conf",
+    "command": "/usr/bin/ganesha.nfsd -F -f /etc/ganesha/ganesha.conf",
     "config_files": [
         {
             "source": "{{ container_config_directory }}/ganesha.conf",
diff --git a/ansible/roles/ceph/templates/ganesha.conf.j2 b/ansible/roles/ceph/templates/ganesha.conf.j2
index ad86afbaf7..3860cdc796 100644
--- a/ansible/roles/ceph/templates/ganesha.conf.j2
+++ b/ansible/roles/ceph/templates/ganesha.conf.j2
@@ -14,7 +14,6 @@ EXPORT
 
 	FSAL {
 		Name = CEPH;
-		User_Id = "admin";
 	}
 }