mirror of https://github.com/ceph/ceph-ansible.git
check if pools already exist before creating them
Add a task to check if pools already exist before we create them. Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>pull/2544/merge
parent
a68091c923
commit
75ed437d4e
|
@ -62,25 +62,41 @@
|
||||||
- keys | length > 0
|
- keys | length > 0
|
||||||
- inventory_hostname in groups.get(client_group_name) | first
|
- 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)
|
- name: create ceph pool(s)
|
||||||
command: >
|
command: >
|
||||||
{{ docker_exec_client_cmd | default('') }} ceph --cluster {{ cluster }}
|
{{ docker_exec_client_cmd | default('') }} ceph --cluster {{ cluster }}
|
||||||
osd pool create {{ item.name }}
|
osd pool create {{ item.0.name }}
|
||||||
{{ item.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}
|
{{ item.0.get('pg_num', hostvars[groups[mon_group_name][0]]['osd_pool_default_pg_num']) }}
|
||||||
{{ item.pgp_num | default(item.pg_num) }}
|
{{ item.0.pgp_num | default(item.0.pg_num) }}
|
||||||
{{ item.rule_name | default("replicated_rule") }}
|
{{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.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) }}
|
{{ 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.type | default("1") == '3' or item.type | default("1") == 'erasure') and item.erasure_profile != '' %}
|
{%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %}
|
||||||
{{ item.erasure_profile }}
|
{{ item.0.erasure_profile }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{{ item.expected_num_objects | default('') }}
|
{{ item.0.expected_num_objects | default('') }}
|
||||||
with_items: "{{ pools }}"
|
with_together:
|
||||||
|
- "{{ pools }}"
|
||||||
|
- "{{ created_pools.results }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
run_once: true
|
run_once: true
|
||||||
|
delegate_to: "{{ groups.get(client_group_name)[0] }}"
|
||||||
when:
|
when:
|
||||||
- pools | length > 0
|
- pools | length > 0
|
||||||
- copy_admin_key
|
- copy_admin_key
|
||||||
- inventory_hostname in groups.get(client_group_name) | first
|
- inventory_hostname in groups.get(client_group_name) | first
|
||||||
|
- item.1.rc != 0
|
||||||
|
|
||||||
- name: kill a dummy container that created pool(s)/key(s)
|
- name: kill a dummy container that created pool(s)/key(s)
|
||||||
command: docker rm -f ceph-create-keys
|
command: docker rm -f ceph-create-keys
|
||||||
|
|
|
@ -1,18 +1,30 @@
|
||||||
---
|
---
|
||||||
|
- 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)
|
- name: create openstack pool(s)
|
||||||
command: >
|
command: >
|
||||||
{{ docker_exec_cmd }} ceph --cluster {{ cluster }}
|
{{ docker_exec_cmd }} ceph --cluster {{ cluster }}
|
||||||
osd pool create {{ item.name }}
|
osd pool create {{ item.0.name }}
|
||||||
{{ item.pg_num }}
|
{{ item.0.pg_num }}
|
||||||
{{ item.pgp_num | default(item.pg_num) }}
|
{{ item.0.pgp_num | default(item.0.pg_num) }}
|
||||||
{{ item.rule_name | default("replicated_rule") }}
|
{{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.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) }}
|
{{ 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.type | default("1") == '3' or item.type | default("1") == 'erasure') and item.erasure_profile != '' %}
|
{%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %}
|
||||||
{{ item.erasure_profile }}
|
{{ item.0.erasure_profile }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{{ item.expected_num_objects | default('') }}
|
{{ item.0.expected_num_objects | default('') }}
|
||||||
with_items: "{{ openstack_pools | unique }}"
|
with_together:
|
||||||
|
- "{{ openstack_pools | unique }}"
|
||||||
|
- "{{ created_pools.results }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
when:
|
||||||
|
- item.1.get('rc', 0) != 0
|
||||||
|
|
||||||
- name: assign rbd application to pool(s)
|
- name: assign rbd application to pool(s)
|
||||||
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} rbd"
|
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} rbd"
|
||||||
|
|
Loading…
Reference in New Issue