- keys | length > 0
- inventory_hostname in groups.get(client_group_name) | first
+- name: list existing pool(s)
+ command: >
+ {{ docker_exec_client_cmd | default('') }} ceph --cluster {{ cluster }}
+ osd pool get {{ item.name }} size
+ with_items: "{{ pools }}"
+ register: created_pools
+ run_once: true
+ failed_when: false
+ delegate_to: "{{ groups.get(client_group_name)[0] }}"
+ when:
+ - copy_admin_key
+
- name: create ceph pool(s)
command: >
{{ docker_exec_client_cmd | default('') }} ceph --cluster {{ cluster }}
- osd pool create {{ item.name }}
- {{ item.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}
- {{ item.pgp_num | default(item.pg_num) }}
- {{ item.rule_name | default("replicated_rule") }}
- {{ 1 if item.type|default(1) == 'replicated' else 3 if item.type|default(1) == 'erasure' else item.type|default(1) }}
- {%- if (item.type | default("1") == '3' or item.type | default("1") == 'erasure') and item.erasure_profile != '' %}
- {{ item.erasure_profile }}
+ osd pool create {{ item.0.name }}
+ {{ item.0.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}
+ {{ item.0.pgp_num | default(item.0.pg_num) }}
+ {{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.rule_name | default('replicated_rule') }}
+ {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
+ {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %}
+ {{ item.0.erasure_profile }}
{%- endif %}
- {{ item.expected_num_objects | default('') }}
- with_items: "{{ pools }}"
+ {{ item.0.expected_num_objects | default('') }}
+ with_together:
+ - "{{ pools }}"
+ - "{{ created_pools.results }}"
changed_when: false
run_once: true
+ delegate_to: "{{ groups.get(client_group_name)[0] }}"
when:
- pools | length > 0
- copy_admin_key
- inventory_hostname in groups.get(client_group_name) | first
+ - item.1.rc != 0
- name: kill a dummy container that created pool(s)/key(s)
command: docker rm -f ceph-create-keys
---
+- name: list existing pool(s)
+ command: >
+ {{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }}
+ osd pool get {{ item.name }} size
+ with_items: "{{ openstack_pools | unique }}"
+ register: created_pools
+ failed_when: false
+
- name: create openstack pool(s)
command: >
{{ docker_exec_cmd }} ceph --cluster {{ cluster }}
- osd pool create {{ item.name }}
- {{ item.pg_num }}
- {{ item.pgp_num | default(item.pg_num) }}
- {{ item.rule_name | default("replicated_rule") }}
- {{ 1 if item.type|default(1) == 'replicated' else 3 if item.type|default(1) == 'erasure' else item.type|default(1) }}
- {%- if (item.type | default("1") == '3' or item.type | default("1") == 'erasure') and item.erasure_profile != '' %}
- {{ item.erasure_profile }}
+ osd pool create {{ item.0.name }}
+ {{ item.0.pg_num }}
+ {{ item.0.pgp_num | default(item.0.pg_num) }}
+ {{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.rule_name | default('replicated_rule') }}
+ {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
+ {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %}
+ {{ item.0.erasure_profile }}
{%- endif %}
- {{ item.expected_num_objects | default('') }}
- with_items: "{{ openstack_pools | unique }}"
+ {{ item.0.expected_num_objects | default('') }}
+ with_together:
+ - "{{ openstack_pools | unique }}"
+ - "{{ created_pools.results }}"
changed_when: false
+ when:
+ - item.1.get('rc', 0) != 0
- name: assign rbd application to pool(s)
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} rbd"