diff --git a/group_vars/clients.yml.sample b/group_vars/clients.yml.sample index 1bd4f6003..c2efad271 100644 --- a/group_vars/clients.yml.sample +++ b/group_vars/clients.yml.sample @@ -15,8 +15,8 @@ dummy: #user_config: false #pools: -# - { name: test, pgs: "{{ pool_default_pg_num }}" } -# - { name: test2, pgs: "{{ pool_default_pg_num }}" } +# - { name: test, pgs: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" } +# - { name: test2, pgs: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" } #keys: # - { name: client.test, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=test'" } diff --git a/group_vars/mons.yml.sample b/group_vars/mons.yml.sample index 844c6dff0..6470030f5 100644 --- a/group_vars/mons.yml.sample +++ b/group_vars/mons.yml.sample @@ -23,7 +23,6 @@ dummy: #cephx: true # CephFS -#pool_default_pg_num: 128 #cephfs_data: cephfs_data #cephfs_metadata: cephfs_metadata #cephfs: cephfs @@ -50,16 +49,16 @@ dummy: #openstack_config: false #openstack_glance_pool: # name: images -# pg_num: "{{ pool_default_pg_num }}" +# pg_num: "{{ osd_pool_default_pg_num }}" #openstack_cinder_pool: # name: volumes -# pg_num: "{{ pool_default_pg_num }}" +# pg_num: "{{ osd_pool_default_pg_num }}" #openstack_nova_pool: # name: vms -# pg_num: "{{ pool_default_pg_num }}" +# pg_num: "{{ osd_pool_default_pg_num }}" #openstack_cinder_backup_pool: # name: backups -# pg_num: "{{ pool_default_pg_num }}" +# pg_num: "{{ osd_pool_default_pg_num }}" #openstack_pools: # - "{{ openstack_glance_pool }}" diff --git a/roles/ceph-client/defaults/main.yml b/roles/ceph-client/defaults/main.yml index 4cc10939b..7ccffebc3 100644 --- a/roles/ceph-client/defaults/main.yml +++ b/roles/ceph-client/defaults/main.yml @@ -7,8 +7,8 @@ fetch_directory: fetch/ user_config: false pools: - - { name: test, pgs: "{{ pool_default_pg_num }}" } - - { name: test2, pgs: "{{ pool_default_pg_num }}" } + - { name: test, pgs: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" } + - { name: test2, pgs: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" } keys: - { name: client.test, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=test'" } diff --git a/roles/ceph-client/tasks/main.yml b/roles/ceph-client/tasks/main.yml index c2b363f62..b0ad7283d 100644 --- a/roles/ceph-client/tasks/main.yml +++ b/roles/ceph-client/tasks/main.yml @@ -1,4 +1,6 @@ --- - include: pre_requisite.yml - include: create_users_keys.yml - when: user_config + when: + - user_config + - ceph_conf_overrides.global.osd_pool_default_pg_num is defined diff --git a/roles/ceph-mon/defaults/main.yml b/roles/ceph-mon/defaults/main.yml index d431e4310..cbe61432b 100644 --- a/roles/ceph-mon/defaults/main.yml +++ b/roles/ceph-mon/defaults/main.yml @@ -15,7 +15,6 @@ monitor_secret: "{{ monitor_keyring.stdout }}" cephx: true # CephFS -pool_default_pg_num: 128 cephfs_data: cephfs_data cephfs_metadata: cephfs_metadata cephfs: cephfs @@ -42,16 +41,16 @@ calamari: false openstack_config: false openstack_glance_pool: name: images - pg_num: "{{ pool_default_pg_num }}" + pg_num: "{{ osd_pool_default_pg_num }}" openstack_cinder_pool: name: volumes - pg_num: "{{ pool_default_pg_num }}" + pg_num: "{{ osd_pool_default_pg_num }}" openstack_nova_pool: name: vms - pg_num: "{{ pool_default_pg_num }}" + pg_num: "{{ osd_pool_default_pg_num }}" openstack_cinder_backup_pool: name: backups - pg_num: "{{ pool_default_pg_num }}" + pg_num: "{{ osd_pool_default_pg_num }}" openstack_pools: - "{{ openstack_glance_pool }}" diff --git a/roles/ceph-mon/tasks/ceph_keys.yml b/roles/ceph-mon/tasks/ceph_keys.yml index 4aeb22923..5292180cc 100644 --- a/roles/ceph-mon/tasks/ceph_keys.yml +++ b/roles/ceph-mon/tasks/ceph_keys.yml @@ -30,6 +30,43 @@ - cephx - groups[restapi_group_name] is defined +# NOTE(leseb): we add a conditional for backward compatibility +# so people that had 'pool_default_pg_num' declared will get +# the same behaviour +# +- name: check if does global key exist in ceph_conf_overrides + set_fact: + global_in_ceph_conf_overrides: "{{ 'global' in ceph_conf_overrides }}" + +- name: check if ceph_conf_overrides.global.osd_pool_default_pg_num is set + set_fact: + osd_pool_default_pg_num_in_overrides: "{{ 'osd_pool_default_pg_num' in ceph_conf_overrides.global }}" + when: global_in_ceph_conf_overrides + +- name: get default value for osd_pool_default_pg_num + shell: | + ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config get osd_pool_default_pg_num | grep -Po '(?<="osd_pool_default_pg_num": ")[^"]*' + failed_when: false + changed_when: false + run_once: true + register: default_pool_default_pg_num + when: (pool_default_pg_num is not defined or not global_in_ceph_conf_overrides) + +- set_fact: + osd_pool_default_pg_num: "{{ pool_default_pg_num }}" + when: pool_default_pg_num is defined + +- set_fact: + osd_pool_default_pg_num: "{{ default_pool_default_pg_num.stdout }}" + when: + - pool_default_pg_num is not defined + - default_pool_default_pg_num.rc == 0 + - ceph_conf_overrides.global.osd_pool_default_pg_num is not defined + +- set_fact: + osd_pool_default_pg_num: "{{ ceph_conf_overrides.global.osd_pool_default_pg_num }}" + when: ceph_conf_overrides.global.osd_pool_default_pg_num is defined + - include: rbd_pool.yml when: ceph_conf_overrides.global.osd_pool_default_pg_num is defined diff --git a/roles/ceph-mon/tasks/create_mds_filesystems.yml b/roles/ceph-mon/tasks/create_mds_filesystems.yml index e114b1511..f5103cbb9 100644 --- a/roles/ceph-mon/tasks/create_mds_filesystems.yml +++ b/roles/ceph-mon/tasks/create_mds_filesystems.yml @@ -4,7 +4,7 @@ # 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: ceph --cluster {{ cluster }} osd pool create {{ item }} {{ pool_default_pg_num }} + command: ceph --cluster {{ cluster }} osd pool create {{ item }} {{ osd_pool_default_pg_num }} with_items: - cephfs_data - cephfs_metadata