mirror of https://github.com/ceph/ceph-ansible.git
ceph-mds: group similar tasks in create_mds_filesystem.yml
Group similar tasks together using block keyword.
Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 1a4dccdbb9
)
pull/3970/head
parent
238a2696a6
commit
8959ed50a5
|
@ -1,74 +1,74 @@
|
||||||
---
|
---
|
||||||
- name: compile a list of pool names
|
- name: check and deploy filesystem pools
|
||||||
set_fact:
|
|
||||||
cephfs_pool_names: "{{ cephfs_pools | map(attribute='name') | list }}"
|
|
||||||
|
|
||||||
- name: check if filesystem pool already exists
|
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
||||||
block:
|
block:
|
||||||
- name: get and store list of filesystem pools
|
- name: check if filesystem pool already exists
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls"
|
block:
|
||||||
changed_when: false
|
- name: compile a list of pool names
|
||||||
register: osd_pool_ls
|
set_fact:
|
||||||
|
cephfs_pool_names: "{{ cephfs_pools | map(attribute='name') | list }}"
|
||||||
|
|
||||||
- name: look whether pools to be created are present in the output
|
- name: get and store list of filesystem pools
|
||||||
set_fact:
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls"
|
||||||
fs_pools_created: True
|
changed_when: false
|
||||||
when: osd_pool_ls.stdout_lines | intersect(cephfs_pool_names) | length > 0
|
register: osd_pool_ls
|
||||||
|
|
||||||
- name: deploy filesystem pools
|
- name: look whether pools to be created are present in the output
|
||||||
when: fs_pools_created is not defined
|
set_fact:
|
||||||
|
fs_pools_created: True
|
||||||
|
when: osd_pool_ls.stdout_lines | intersect(cephfs_pool_names) | length > 0
|
||||||
|
|
||||||
|
- name: deploy filesystem pools
|
||||||
|
when: fs_pools_created is not defined
|
||||||
|
block:
|
||||||
|
- name: create filesystem pools
|
||||||
|
command: >
|
||||||
|
{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }}
|
||||||
|
osd pool create {{ item.name }}
|
||||||
|
{{ item.pg_num | default(item.pgs) | default(osd_pool_default_pg_num) }}
|
||||||
|
{{ item.pgp_num | default(item.pgs) | default(item.pg_num) | default(osd_pool_default_pg_num) }}
|
||||||
|
{{ 'replicated_rule' if not item.rule_name | default('replicated_rule') else 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 }}
|
||||||
|
{%- endif %}
|
||||||
|
{{ item.expected_num_objects | default('') }}
|
||||||
|
changed_when: false
|
||||||
|
with_items:
|
||||||
|
- "{{ cephfs_pools }}"
|
||||||
|
|
||||||
|
- name: customize pool size
|
||||||
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}"
|
||||||
|
with_items: "{{ cephfs_pools | unique }}"
|
||||||
|
changed_when: false
|
||||||
|
when: item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|
||||||
|
|
||||||
|
- name: customize pool min_size
|
||||||
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} min_size {{ item.min_size | default(osd_pool_default_min_size) }}"
|
||||||
|
with_items: "{{ cephfs_pools | unique }}"
|
||||||
|
changed_when: false
|
||||||
|
when: (item.min_size | default(osd_pool_default_min_size))|int > ceph_osd_pool_default_min_size
|
||||||
|
|
||||||
|
- name: assign application to cephfs pools
|
||||||
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item }} cephfs"
|
||||||
|
with_items:
|
||||||
|
- "{{ cephfs_data }}"
|
||||||
|
- "{{ cephfs_metadata }}"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: check and create ceph filesystem
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
||||||
block:
|
block:
|
||||||
- name: create filesystem pools
|
- name: check if ceph filesystem already exists
|
||||||
command: >
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}"
|
||||||
{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
register: check_existing_cephfs
|
||||||
osd pool create {{ item.name }}
|
|
||||||
{{ item.pg_num | default(item.pgs) | default(osd_pool_default_pg_num) }}
|
|
||||||
{{ item.pgp_num | default(item.pgs) | default(item.pg_num) | default(osd_pool_default_pg_num) }}
|
|
||||||
{{ 'replicated_rule' if not item.rule_name | default('replicated_rule') else 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 }}
|
|
||||||
{%- endif %}
|
|
||||||
{{ item.expected_num_objects | default('') }}
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
with_items:
|
failed_when: false
|
||||||
- "{{ cephfs_pools }}"
|
|
||||||
|
|
||||||
- name: customize pool size
|
- name: create ceph filesystem
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}"
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}"
|
||||||
with_items: "{{ cephfs_pools | unique }}"
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|
when: check_existing_cephfs.rc != 0
|
||||||
|
|
||||||
- name: customize pool min_size
|
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} min_size {{ item.min_size | default(osd_pool_default_min_size) }}"
|
|
||||||
with_items: "{{ cephfs_pools | unique }}"
|
|
||||||
changed_when: false
|
|
||||||
when: (item.min_size | default(osd_pool_default_min_size))|int > ceph_osd_pool_default_min_size
|
|
||||||
|
|
||||||
- name: check if ceph filesystem already exists
|
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}"
|
|
||||||
register: check_existing_cephfs
|
|
||||||
changed_when: false
|
|
||||||
failed_when: false
|
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
||||||
|
|
||||||
- name: create ceph filesystem
|
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}"
|
|
||||||
changed_when: false
|
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
||||||
when: check_existing_cephfs.rc != 0
|
|
||||||
|
|
||||||
- name: assign application to cephfs pools
|
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item }} cephfs"
|
|
||||||
with_items:
|
|
||||||
- "{{ cephfs_data }}"
|
|
||||||
- "{{ cephfs_metadata }}"
|
|
||||||
changed_when: false
|
|
||||||
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
||||||
when: check_existing_cephfs.rc != 0
|
|
||||||
|
|
||||||
- name: set max_mds
|
- name: set max_mds
|
||||||
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs set {{ cephfs }} max_mds {{ mds_max_mds }}"
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs set {{ cephfs }} max_mds {{ mds_max_mds }}"
|
||||||
|
|
Loading…
Reference in New Issue