]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-rgw: allow specifying crush rule on pool
authorDimitri Savineau <dsavinea@redhat.com>
Mon, 17 Aug 2020 17:55:47 +0000 (13:55 -0400)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Fri, 11 Sep 2020 00:36:54 +0000 (20:36 -0400)
We already support specifiying a custom crush rule during pool creation
in ceph-osd role but not in ceph-rgw role.
This patch adds the missing code to implement this feature.
Note this is only available for replicated pool not erasure. The rule
must also exist prior the pool creation.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1855439
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit cb8f0237e1fe7b890d20d47b5d023a6c618cbd4c)

group_vars/rgws.yml.sample
roles/ceph-rgw/defaults/main.yml
roles/ceph-rgw/tasks/rgw_create_pools.yml

index 7728d35ae1e5f6bbc0dc9ced524cf545e4d0de20..69b1fc0e8c987710bd7c9e61c22e2af4aa544b99 100644 (file)
@@ -50,6 +50,9 @@ dummy:
 #     each pool.
 #   - If a pool's type is 'ec', k and m values must be set via
 #     the ec_k, and ec_m variables.
+#   - The rule_name key can be used with a specific crush rule value (must exist).
+#     If the key doesn't exist it falls back to the default replicated_rule.
+#     This only works for replicated pool type not erasure.
 
 #rgw_create_pools:
 #  "{{ rgw_zone }}.rgw.buckets.data":
@@ -74,6 +77,7 @@ dummy:
 #    pg_num: 8
 #    size: 3
 #    type: replicated
+#    rule_name: foo
 
 
 ##########
index 96ffd09c175f842a969d415b2ee4260ea644baa1..a25468b8dbdbc2bfda2118e627b95237e4d9d002 100644 (file)
@@ -42,6 +42,9 @@ copy_admin_key: false
 #     each pool.
 #   - If a pool's type is 'ec', k and m values must be set via
 #     the ec_k, and ec_m variables.
+#   - The rule_name key can be used with a specific crush rule value (must exist).
+#     If the key doesn't exist it falls back to the default replicated_rule.
+#     This only works for replicated pool type not erasure.
 
 #rgw_create_pools:
 #  "{{ rgw_zone }}.rgw.buckets.data":
@@ -66,6 +69,7 @@ copy_admin_key: false
 #    pg_num: 8
 #    size: 3
 #    type: replicated
+#    rule_name: foo
 
 
 ##########
index 0b338407a62d0fc145c06e595e715eaf0b63975f..76c2f8a4b0d2e514ab264ea695024500a7410e6f 100644 (file)
@@ -37,7 +37,7 @@
     - item.value.type == 'ec'
 
 - name: create replicated pools for rgw
-  command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num | default(osd_pool_default_pg_num) }} replicated"
+  command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd pool create {{ item.key }} {{ item.value.pg_num | default(osd_pool_default_pg_num) }} replicated {{ item.value.rule_name | default(ceph_osd_pool_default_crush_rule_name) }}"
   changed_when: false
   register: result
   retries: 60
     - item.value.type is not defined or item.value.type == 'replicated'
     - item.value.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
 
+- name: customize replicated pool crush_rule
+  command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd pool set {{ item.key }} crush_rule {{ item.value.rule_name | default(ceph_osd_pool_default_crush_rule_name) }}"
+  register: result
+  retries: 60
+  delay: 3
+  until: result is succeeded
+  loop: "{{ rgw_create_pools | dict2items }}"
+  delegate_to: "{{ groups[mon_group_name][0] }}"
+  changed_when: false
+  when:
+    - item.value.type is not defined or item.value.type == 'replicated'
+    - item.value.rule_name | default(ceph_osd_pool_default_crush_rule_name)
+
 - 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