From: Sébastien Han Date: Mon, 3 Dec 2018 10:59:49 +0000 (+0100) Subject: ceph_key: allow setting 'dest' to a file X-Git-Tag: v4.0.0beta1~137 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=23f685b3526482cbea442a4625bfe8f0a9724f43;p=ceph-ansible.git ceph_key: allow setting 'dest' to a file 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 --- diff --git a/library/ceph_key.py b/library/ceph_key.py index 710f33901..e0762affa 100644 --- a/library/ceph_key.py +++ b/library/ceph_key.py @@ -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 +