]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-rgw: Make sure pool name templates are expanded
authorBenoît Knecht <bknecht@protonmail.ch>
Mon, 11 May 2020 13:49:32 +0000 (15:49 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Mon, 11 May 2020 18:00:08 +0000 (14:00 -0400)
It is common to set templated pool names in `rgw_create_pools`, e.g.

```yaml
rgw_create_pools:
  "{{ rgw_zone }}.rgw.buckets.index":
    pg_num: 16
    size: 3
    type: replicated
```

This worked fine with Ansible 2.8, but broke in Ansible 2.9 due to a change in
the way `with_dict` works [1].

This commit replaces the use of `with_dict` with

```yaml
loop: "{{ rgw_create_pools | dict2items }}"
```

which works as intended and expands the template in the pool name.

[1]: https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.9.html#loops

Closes #5348

Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
(cherry picked from commit d2b7670c7dea29bd1072b65ce2ccdccccf97550d)

roles/ceph-rgw/tasks/rgw_create_pools.yml

index 00215660f4618f7d82011e64e7e64d7e6739da27..79b4d62be45626fd07cd82cb10146830e63f4e39 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: remove ec profile
   command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd erasure-code-profile rm {{ item.value.ec_profile }}"
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   changed_when: false
   when:
@@ -11,7 +11,7 @@
 
 - name: set ec profile
   command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd erasure-code-profile set {{ item.value.ec_profile }} k={{ item.value.ec_k }} m={{ item.value.ec_m }}"
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   changed_when: false
   when:
@@ -20,7 +20,7 @@
 
 - name: set crush rule
   command: "{{ container_exec_cmd }} ceph --connect-timeout 10 --cluster {{ cluster }} osd crush rule create-erasure {{ item.key }} {{ item.value.ec_profile }}"
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   changed_when: false
   when:
@@ -29,7 +29,7 @@
 
 - name: create ec 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) }} erasure {{ item.value.ec_profile }}"
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   changed_when: false
   when:
@@ -43,7 +43,7 @@
   retries: 60
   delay: 3
   until: result is succeeded
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   when: item.value.type is not defined or item.value.type == 'replicated'
 
@@ -53,7 +53,7 @@
   retries: 60
   delay: 3
   until: result is succeeded
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"
   changed_when: false
   when:
@@ -67,5 +67,5 @@
   delay: 3
   until: result is succeeded
   changed_when: false
-  with_dict: "{{ rgw_create_pools }}"
+  loop: "{{ rgw_create_pools | dict2items }}"
   delegate_to: "{{ groups[mon_group_name][0] }}"