From 66426e131649ef7eadc8414d33f80ac1003a090b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 27 Jul 2021 09:31:35 +0200 Subject: [PATCH] ceph-rgw: Set pg_num on RGW pool if required MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the `pg_num` value specified in `rgw_create_pools` is different from the actual value in the cluster, apply it with `ceph osd pool set`. This corresponds to the behavior of the `ceph_pool` module used in Ceph Ansible 5.0 onward. Also avoid setting the pool application if it's already done. Signed-off-by: Benoît Knecht --- roles/ceph-rgw/tasks/rgw_create_pools.yml | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/roles/ceph-rgw/tasks/rgw_create_pools.yml b/roles/ceph-rgw/tasks/rgw_create_pools.yml index 76c2f8a4b..207c14199 100644 --- a/roles/ceph-rgw/tasks/rgw_create_pools.yml +++ b/roles/ceph-rgw/tasks/rgw_create_pools.yml @@ -73,12 +73,39 @@ - item.value.type is not defined or item.value.type == 'replicated' - item.value.rule_name | default(ceph_osd_pool_default_crush_rule_name) +- name: get pool details + command: "{{ container_exec_cmd }} ceph --connect-timeout=10 --cluster={{ cluster }} --format=json osd pool ls detail" + register: result + retries: 60 + delay: 3 + until: result is succeeded + delegate_to: "{{ groups[mon_group_name][0] }}" + changed_when: false + check_mode: false + +- name: set rgw_osd_pool_ls_detail fact + set_fact: + rgw_osd_pool_ls_detail: "{{ result.stdout | from_json }}" + - name: set the rgw_create_pools pools application to rgw command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd pool application enable {{ item.key }} rgw" register: result retries: 60 delay: 3 until: result is succeeded - changed_when: false loop: "{{ rgw_create_pools | dict2items }}" delegate_to: "{{ groups[mon_group_name][0] }}" + when: > + 'rgw' not in (rgw_osd_pool_ls_detail | selectattr('pool_name', 'eq', item.key) | first).application_metadata + +- name: set pool pg_num + command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd pool set {{ item.key }} pg_num {{ item.value.pg_num }}" + register: result + retries: 60 + delay: 3 + until: result is succeeded + loop: "{{ rgw_create_pools | dict2items }}" + delegate_to: "{{ groups[mon_group_name][0] }}" + when: + - item.value.pg_num is defined + - (rgw_osd_pool_ls_detail | selectattr('pool_name', 'eq', item.key) | first).pg_num != item.value.pg_num -- 2.39.5