From e00b745a6c3998ff5a679444037204449fcbdde6 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 23 Feb 2017 16:06:04 +0100 Subject: [PATCH] ceph-mon: Check if ceph filesystem exists Check if ceph filesystem already exists before creating it. If the ceph filesystem doesn't exist, execute the task only on one node. Fix: #1314 Signed-off-by: Guillaume Abrioux --- .../ceph-mon/tasks/create_mds_filesystems.yml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/roles/ceph-mon/tasks/create_mds_filesystems.yml b/roles/ceph-mon/tasks/create_mds_filesystems.yml index d9a89ca77..6e7b82d98 100644 --- a/roles/ceph-mon/tasks/create_mds_filesystems.yml +++ b/roles/ceph-mon/tasks/create_mds_filesystems.yml @@ -10,21 +10,31 @@ - cephfs_metadata changed_when: false +- name: check if ceph filesystem already exists + command: ceph --cluster {{ cluster }} fs get {{ cephfs }} + register: check_existing_cephfs + changed_when: false + failed_when: false + when: inventory_hostname == groups.mons|last + - name: create ceph filesystem command: ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }} changed_when: false + when: + - inventory_hostname == groups.mons|last + - check_existing_cephfs.rc != 0 - name: allow multimds command: ceph --cluster {{ cluster }} fs set {{ cephfs }} allow_multimds true --yes-i-really-mean-it changed_when: false when: - - ceph_release_num.{{ ceph_release }} >= ceph_release_num.jewel - - mds_allow_multimds + - ceph_release_num.{{ ceph_release }} >= ceph_release_num.jewel + - mds_allow_multimds - name: set max_mds command: ceph --cluster {{ cluster }} fs set {{ cephfs }} max_mds {{ mds_max_mds }} changed_when: false when: - - ceph_release_num.{{ ceph_release }} >= ceph_release_num.jewel - - mds_allow_multimds - - mds_max_mds > 1 + - ceph_release_num.{{ ceph_release }} >= ceph_release_num.jewel + - mds_allow_multimds + - mds_max_mds > 1