From b49f9bda21d73fbe4cb11e505d2cdc06e056f04f Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Thu, 12 Oct 2017 14:55:53 +0200 Subject: [PATCH] mds: precisely define cephfs pool MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We now have a variable called ceph_pools that is mandatory when deploying a MDS. It's a dictionnary that contains a pool name and a PG count. PG count is mandatory and must be set, the playbook will fail otherwise. Closes: https://github.com/ceph/ceph-ansible/issues/2017 Signed-off-by: Sébastien Han --- group_vars/mons.yml.sample | 28 ++++++++++++------- roles/ceph-mon/defaults/main.yml | 28 ++++++++++++------- roles/ceph-mon/tasks/check_mandatory_vars.yml | 8 ++++++ .../ceph-mon/tasks/create_mds_filesystems.yml | 14 ++++------ .../centos/7/cluster/group_vars/mons | 4 +++ .../centos/7/docker/group_vars/mons | 4 +++ .../ubuntu/16.04/cluster/group_vars/mons | 4 +++ 7 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 tests/functional/centos/7/cluster/group_vars/mons create mode 100644 tests/functional/centos/7/docker/group_vars/mons create mode 100644 tests/functional/ubuntu/16.04/cluster/group_vars/mons diff --git a/group_vars/mons.yml.sample b/group_vars/mons.yml.sample index 2f73d2b82..0c3395e29 100644 --- a/group_vars/mons.yml.sample +++ b/group_vars/mons.yml.sample @@ -12,18 +12,12 @@ dummy: ########### # GENERAL # ########### - #mon_group_name: mons # ACTIVATE BOTH FSID AND MONITOR_SECRET VARIABLES FOR NON-VAGRANT DEPLOYMENT #monitor_secret: "{{ monitor_keyring.stdout }}" #admin_secret: 'admin_secret' -# CephFS -#cephfs_data: cephfs_data -#cephfs_metadata: cephfs_metadata -#cephfs: cephfs - # Secure your cluster # This will set the following flags on all the pools: # * nosizechange @@ -43,9 +37,21 @@ dummy: #calamari_debug: false -############# -# crush rules -############# +########## +# CEPHFS # +########## +#cephfs: cephfs # name of the ceph filesystem +#cephfs_data: cephfs_data # name of the data pool for a given filesystem +#cephfs_metadata: cephfs_metadata # name of the metadata pool for a given filesystem + +#cephfs_pools: +# - { name: "{{ cephfs_data }}", pgs: "" } +# - { name: "{{ cephfs_metadata }}", pgs: "" } + + +############### +# CRUSH RULES # +############### #crush_rule_config: false #crush_rule_hdd: @@ -63,10 +69,11 @@ dummy: #crush_rules: # - "{{ crush_rule_hdd }}" # - "{{ crush_rule_ssd }}" + + ############# # OPENSTACK # ############# - #openstack_config: false #openstack_glance_pool: # name: images @@ -110,6 +117,7 @@ dummy: # - { name: client.gnocchi, key: "$(ceph-authtool --gen-print-key)", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_gnocchi_pool.name }}", mode: "0600", acls: [] } # - { name: client.openstack, key: "$(ceph-authtool --gen-print-key)", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=images, allow rwx pool=vms, allow rwx pool=volumes, allow rwx pool=backups", mode: "0600", acls: [] } + ########## # DOCKER # ########## diff --git a/roles/ceph-mon/defaults/main.yml b/roles/ceph-mon/defaults/main.yml index ca3c07d95..c03faa737 100644 --- a/roles/ceph-mon/defaults/main.yml +++ b/roles/ceph-mon/defaults/main.yml @@ -4,18 +4,12 @@ ########### # GENERAL # ########### - mon_group_name: mons # ACTIVATE BOTH FSID AND MONITOR_SECRET VARIABLES FOR NON-VAGRANT DEPLOYMENT monitor_secret: "{{ monitor_keyring.stdout }}" admin_secret: 'admin_secret' -# CephFS -cephfs_data: cephfs_data -cephfs_metadata: cephfs_metadata -cephfs: cephfs - # Secure your cluster # This will set the following flags on all the pools: # * nosizechange @@ -35,9 +29,21 @@ calamari: false calamari_debug: false -############# -# crush rules -############# +########## +# CEPHFS # +########## +cephfs: cephfs # name of the ceph filesystem +cephfs_data: cephfs_data # name of the data pool for a given filesystem +cephfs_metadata: cephfs_metadata # name of the metadata pool for a given filesystem + +cephfs_pools: + - { name: "{{ cephfs_data }}", pgs: "" } + - { name: "{{ cephfs_metadata }}", pgs: "" } + + +############### +# CRUSH RULES # +############### crush_rule_config: false crush_rule_hdd: @@ -55,10 +61,11 @@ crush_rule_ssd: crush_rules: - "{{ crush_rule_hdd }}" - "{{ crush_rule_ssd }}" + + ############# # OPENSTACK # ############# - openstack_config: false openstack_glance_pool: name: images @@ -102,6 +109,7 @@ openstack_keys: - { name: client.gnocchi, key: "$(ceph-authtool --gen-print-key)", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_gnocchi_pool.name }}", mode: "0600", acls: [] } - { name: client.openstack, key: "$(ceph-authtool --gen-print-key)", mon_cap: "allow r", osd_cap: "allow class-read object_prefix rbd_children, allow rwx pool=images, allow rwx pool=vms, allow rwx pool=volumes, allow rwx pool=backups", mode: "0600", acls: [] } + ########## # DOCKER # ########## diff --git a/roles/ceph-mon/tasks/check_mandatory_vars.yml b/roles/ceph-mon/tasks/check_mandatory_vars.yml index cb0b95070..395838242 100644 --- a/roles/ceph-mon/tasks/check_mandatory_vars.yml +++ b/roles/ceph-mon/tasks/check_mandatory_vars.yml @@ -6,3 +6,11 @@ - monitor_interface == 'interface' - monitor_address == '0.0.0.0' - monitor_address_block | length == 0 + +- name: make sure pg num is set for cephfs pools + fail: + msg: "You must set pg num for your cephfs pools, see the cephfs_pools variable." + with_items: "{{ cephfs_pools }}" + when: + - inventory_hostname in groups.get(mds_group_name, []) + - item.pgs == '' diff --git a/roles/ceph-mon/tasks/create_mds_filesystems.yml b/roles/ceph-mon/tasks/create_mds_filesystems.yml index a1292ee49..313f18815 100644 --- a/roles/ceph-mon/tasks/create_mds_filesystems.yml +++ b/roles/ceph-mon/tasks/create_mds_filesystems.yml @@ -1,14 +1,9 @@ --- -# NOTE (leseb): in the present playbook the conditional is done on the task -# We don't do this in main.yml because of the 'docker' variable, when set to true -# the role 'ceph-common' doesn't get inherited so the condition can not be evaluate -# since those check are performed by the ceph-common role - name: create filesystem pools - command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool create {{ item }} {{ osd_pool_default_pg_num }}" - with_items: - - "{{ cephfs_data }}" - - "{{ cephfs_metadata }}" + command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool create {{ item.name }} {{ item.pgs }}" changed_when: false + with_items: + - "{{ cephfs_pools }}" - name: check if ceph filesystem already exists command: "{{docker_exec_cmd }} ceph --cluster {{ cluster }} fs get {{ cephfs }}" @@ -19,7 +14,8 @@ - name: create ceph filesystem command: "{{ docker_exec_cmd}} ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}" changed_when: false - when: check_existing_cephfs.rc != 0 + when: + - check_existing_cephfs.rc != 0 - name: allow multimds command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} fs set {{ cephfs }} allow_multimds true --yes-i-really-mean-it" diff --git a/tests/functional/centos/7/cluster/group_vars/mons b/tests/functional/centos/7/cluster/group_vars/mons new file mode 100644 index 000000000..acb09490a --- /dev/null +++ b/tests/functional/centos/7/cluster/group_vars/mons @@ -0,0 +1,4 @@ +--- +cephfs_pools: + - { name: "{{ cephfs_data }}", pgs: "8" } + - { name: "{{ cephfs_metadata }}", pgs: "8" } diff --git a/tests/functional/centos/7/docker/group_vars/mons b/tests/functional/centos/7/docker/group_vars/mons new file mode 100644 index 000000000..acb09490a --- /dev/null +++ b/tests/functional/centos/7/docker/group_vars/mons @@ -0,0 +1,4 @@ +--- +cephfs_pools: + - { name: "{{ cephfs_data }}", pgs: "8" } + - { name: "{{ cephfs_metadata }}", pgs: "8" } diff --git a/tests/functional/ubuntu/16.04/cluster/group_vars/mons b/tests/functional/ubuntu/16.04/cluster/group_vars/mons new file mode 100644 index 000000000..acb09490a --- /dev/null +++ b/tests/functional/ubuntu/16.04/cluster/group_vars/mons @@ -0,0 +1,4 @@ +--- +cephfs_pools: + - { name: "{{ cephfs_data }}", pgs: "8" } + - { name: "{{ cephfs_metadata }}", pgs: "8" } -- 2.47.3