From f0195e97ed187cb38c91222c8f70d6e1fbffc171 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 21 Nov 2018 11:00:11 +0100 Subject: [PATCH] refact osd pool size customization Add real default value for osd pool size customization. Ceph itself has an `osd_pool_default_size` default value to `3`. If users don't specify a pool size in various pools definition within ceph-ansible, we should default to `3`. By the way, this kind of condition isn't really clear: ``` when: - rbd_pool_size | default ("") ``` we should try to get the customized value then default to what is in `osd_pool_default_size` (which has its default value pointing to `ceph_osd_pool_default_size` (`3`) as well) and compare it to `ceph_osd_pool_default_size`. Signed-off-by: Guillaume Abrioux (cherry picked from commit 7774069d45477df9f37c98bc414b3bf38cf41feb) --- group_vars/iscsigws.yml.sample | 2 +- roles/ceph-client/tasks/create_users_keys.yml | 4 ++-- roles/ceph-defaults/tasks/facts.yml | 4 ++++ roles/ceph-iscsi-gw/defaults/main.yml | 2 +- roles/ceph-iscsi-gw/tasks/common.yml | 4 ++-- roles/ceph-mds/tasks/create_mds_filesystems.yml | 5 +++-- roles/ceph-osd/tasks/openstack_config.yml | 5 +++-- roles/ceph-rgw/tasks/main.yml | 5 +++-- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/group_vars/iscsigws.yml.sample b/group_vars/iscsigws.yml.sample index 5dfe68d20..4ab76d2c5 100644 --- a/group_vars/iscsigws.yml.sample +++ b/group_vars/iscsigws.yml.sample @@ -64,7 +64,7 @@ dummy: # Whether or not to generate secure certificate to iSCSI gateway nodes #generate_crt: False -#rbd_pool_size: "" +#rbd_pool_size: "{{ osd_pool_default_size }}" ################## # RBD-TARGET-API # diff --git a/roles/ceph-client/tasks/create_users_keys.yml b/roles/ceph-client/tasks/create_users_keys.yml index cd2eb0cef..9151c695d 100644 --- a/roles/ceph-client/tasks/create_users_keys.yml +++ b/roles/ceph-client/tasks/create_users_keys.yml @@ -122,13 +122,13 @@ - name: customize pool size command: > {{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} - osd pool set {{ item.name }} size {{ item.size | default('') }} + osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }} with_items: "{{ pools | unique }}" delegate_to: "{{ delegated_node }}" changed_when: false when: - pools | length > 0 - - item.size | default ("") != "" + - item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size - name: get client cephx keys copy: diff --git a/roles/ceph-defaults/tasks/facts.yml b/roles/ceph-defaults/tasks/facts.yml index 39b28555c..4a3f6cf4c 100644 --- a/roles/ceph-defaults/tasks/facts.yml +++ b/roles/ceph-defaults/tasks/facts.yml @@ -244,5 +244,9 @@ set_fact: osd_pool_default_pg_num: "{{ ceph_conf_overrides.get('global', {}).get('osd_pool_default_pg_num', ceph_osd_pool_default_pg_num) }}" +- name: set_fact osd_pool_default_size + set_fact: + osd_pool_default_size: "{{ ceph_conf_overrides.get('global', {}).get('osd_pool_default_size', ceph_osd_pool_default_size) }}" + - name: populate service facts service_facts: diff --git a/roles/ceph-iscsi-gw/defaults/main.yml b/roles/ceph-iscsi-gw/defaults/main.yml index 5ec740b14..5ffd64bb7 100644 --- a/roles/ceph-iscsi-gw/defaults/main.yml +++ b/roles/ceph-iscsi-gw/defaults/main.yml @@ -56,7 +56,7 @@ client_connections: {} # Whether or not to generate secure certificate to iSCSI gateway nodes generate_crt: False -rbd_pool_size: "" +rbd_pool_size: "{{ osd_pool_default_size }}" ################## # RBD-TARGET-API # diff --git a/roles/ceph-iscsi-gw/tasks/common.yml b/roles/ceph-iscsi-gw/tasks/common.yml index a40b75506..3d4a556fd 100644 --- a/roles/ceph-iscsi-gw/tasks/common.yml +++ b/roles/ceph-iscsi-gw/tasks/common.yml @@ -41,8 +41,8 @@ delegate_to: "{{ groups[mon_group_name][0] }}" - name: customize pool size - command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set rbd size {{ rbd_pool_size | default('') }}" + command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set rbd size {{ rbd_pool_size | default(osd_pool_default_size) }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false when: - - rbd_pool_size | default ("") != "" + - rbd_pool_size | default(osd_pool_default_size) != ceph_osd_pool_default_size diff --git a/roles/ceph-mds/tasks/create_mds_filesystems.yml b/roles/ceph-mds/tasks/create_mds_filesystems.yml index 0f9a5d451..208aa8ae0 100644 --- a/roles/ceph-mds/tasks/create_mds_filesystems.yml +++ b/roles/ceph-mds/tasks/create_mds_filesystems.yml @@ -9,11 +9,12 @@ - "{{ cephfs_pools }}" - name: customize pool size - command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default('') }}" + command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}" with_items: "{{ cephfs_pools | unique }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false - when: item.size | default ("") != "" + when: + - item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size - name: check if ceph filesystem already exists command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}" diff --git a/roles/ceph-osd/tasks/openstack_config.yml b/roles/ceph-osd/tasks/openstack_config.yml index c42d1f985..4bc3bbf9f 100644 --- a/roles/ceph-osd/tasks/openstack_config.yml +++ b/roles/ceph-osd/tasks/openstack_config.yml @@ -43,11 +43,12 @@ - name: customize pool size command: > {{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} - osd pool set {{ item.name }} size {{ item.size | default('') }} + osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }} with_items: "{{ openstack_pools | unique }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false - when: item.size | default ("") != "" + when: + - item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size - name: assign application to pool(s) command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} {{ item.application }}" diff --git a/roles/ceph-rgw/tasks/main.yml b/roles/ceph-rgw/tasks/main.yml index e239c113c..f3941b126 100644 --- a/roles/ceph-rgw/tasks/main.yml +++ b/roles/ceph-rgw/tasks/main.yml @@ -34,9 +34,10 @@ run_once: true - name: customize pool size - command: "{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool set {{ item.key }} size {{ item.size | default('') }}" + command: "{{ docker_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool set {{ item.key }} size {{ item.size | default(osd_pool_default_size) }}" with_dict: "{{ rgw_create_pools }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false run_once: true - when: item.size | default ("") != "" + when: + - item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size