Skip to content

Commit

Permalink
ceph-rgw: Make sure pool name templates are expanded
Browse files Browse the repository at this point in the history
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 d2b7670)
  • Loading branch information
BenoitKnecht authored and dsavineau committed Jun 3, 2020
1 parent 8c4190e commit e454b34
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions roles/ceph-rgw/tasks/rgw_create_pools.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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'

Expand All @@ -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:
Expand All @@ -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] }}"

0 comments on commit e454b34

Please sign in to comment.