]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph_key: allow setting 'dest' to a file
authorSébastien Han <seb@redhat.com>
Mon, 3 Dec 2018 10:59:49 +0000 (11:59 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 3 Dec 2018 13:39:43 +0000 (14:39 +0100)
This is useful in situations where you fetch the key from the mon store
and want to write the file with a different name to a dedicated
directory. This is important when fetching the mgr key, they are created
as mgr.ceph-mon2 but we want them in /var/lib/ceph/mgr/ceph-ceph-mon0/keyring

Signed-off-by: Sébastien Han <seb@redhat.com>
library/ceph_key.py

index 710f339013e4a9eb618e2bd8c97989cefe75a385..e0762affab080c19b58394e50b1f9ea6b1bf3caa 100644 (file)
@@ -83,7 +83,7 @@ options:
         default: True
     dest:
         description:
-            - Destination to write the keyring
+            - Destination to write the keyring, can a file or a directory
         required: false
         default: /etc/ceph/
     fetch_initial_keys:
@@ -568,9 +568,13 @@ def run_module():
         if not caps:
             fatal("Capabilities must be provided when state is 'present'", module)  # noqa E501
 
-        # Build a different path for bootstrap keys as there are stored as
-        # /var/lib/ceph/bootstrap-rbd/ceph.keyring
-        if 'bootstrap' in dest:
+        # if dest is not a directory, the user wants to change the file's name
+        # (e,g: /etc/ceph/ceph.mgr.ceph-mon2.keyring)
+        if not os.path.isdir(dest):
+            file_path = dest
+        elif 'bootstrap' in dest:
+            # Build a different path for bootstrap keys as there are stored as
+            # /var/lib/ceph/bootstrap-rbd/ceph.keyring
             file_path = os.path.join(dest + "/" + cluster + ".keyring")
         else:
             file_path = os.path.join(dest + "/" + cluster +