2018-05-23 11:07:38 +08:00
|
|
|
---
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: check and deploy filesystem pools
|
2019-02-12 11:15:44 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
block:
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: check if filesystem pool already exists
|
|
|
|
block:
|
|
|
|
- name: compile a list of pool names
|
|
|
|
set_fact:
|
|
|
|
cephfs_pool_names: "{{ cephfs_pools | map(attribute='name') | list }}"
|
2019-02-12 11:15:44 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: get and store list of filesystem pools
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls"
|
2019-04-24 17:08:15 +08:00
|
|
|
changed_when: false
|
|
|
|
register: osd_pool_ls
|
2019-02-12 11:15:44 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: look whether pools to be created are present in the output
|
|
|
|
set_fact:
|
|
|
|
fs_pools_created: True
|
|
|
|
when: osd_pool_ls.stdout_lines | intersect(cephfs_pool_names) | length > 0
|
2018-10-01 23:11:13 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: deploy filesystem pools
|
|
|
|
when: fs_pools_created is not defined
|
|
|
|
block:
|
|
|
|
- name: create filesystem pools
|
|
|
|
command: >
|
2019-11-18 17:49:17 +08:00
|
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
2019-04-24 17:08:15 +08:00
|
|
|
osd pool create {{ item.name }}
|
2020-02-28 23:03:15 +08:00
|
|
|
{{ item.pg_num | default(osd_pool_default_pg_num) if not item.pg_autoscale_mode | default(False) | bool else 16 }}
|
|
|
|
{{ item.pgp_num | default(item.pg_num) | default(osd_pool_default_pg_num) if not item.pg_autoscale_mode | default(False) | bool else '' }}
|
2020-02-28 18:41:00 +08:00
|
|
|
{%- if item.type | default(1) | int == 1 or item.type | default('replicated') == 'replicated' %}
|
|
|
|
replicated
|
|
|
|
{{ item.rule_name | default(osd_pool_default_crush_rule) }}
|
2020-02-28 23:03:15 +08:00
|
|
|
{{ item.expected_num_objects | default(0) }}
|
2020-02-28 18:41:00 +08:00
|
|
|
{%- else %}
|
|
|
|
erasure
|
2019-04-24 17:08:15 +08:00
|
|
|
{{ item.erasure_profile }}
|
|
|
|
{%- endif %}
|
|
|
|
changed_when: false
|
|
|
|
with_items:
|
|
|
|
- "{{ cephfs_pools }}"
|
2018-05-23 11:07:38 +08:00
|
|
|
|
2020-02-28 23:03:15 +08:00
|
|
|
- name: set the target ratio on pool(s)
|
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} target_size_ratio {{ item.target_size_ratio }}"
|
|
|
|
with_items: "{{ cephfs_pools | unique }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when: item.pg_autoscale_mode | default(False) | bool
|
|
|
|
|
|
|
|
- name: set pg_autoscale_mode value on pool(s)
|
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} pg_autoscale_mode {{ item.pg_autoscale_mode | default(False) | ternary('on', 'warn') }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
with_items: "{{ cephfs_pools | unique }}"
|
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: customize pool size
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
with_items: "{{ cephfs_pools | unique }}"
|
|
|
|
changed_when: false
|
|
|
|
when: item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|
2019-03-01 04:58:31 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: customize pool min_size
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} min_size {{ item.min_size | default(osd_pool_default_min_size) }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
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
|
2018-05-23 11:07:38 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: assign application to cephfs pools
|
2018-04-10 17:32:58 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} {{ item.application }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
with_items:
|
2018-04-10 17:32:58 +08:00
|
|
|
- "{{ cephfs_data_pool }}"
|
|
|
|
- "{{ cephfs_metadata_pool }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
changed_when: false
|
2018-05-23 11:07:38 +08:00
|
|
|
|
2019-04-24 17:08:15 +08:00
|
|
|
- name: check and create ceph filesystem
|
2018-06-29 17:48:01 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
block:
|
|
|
|
- name: check if ceph filesystem already exists
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
register: check_existing_cephfs
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: create ceph filesystem
|
2018-04-10 17:32:58 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata_pool.name }} {{ cephfs_data_pool.name }}"
|
2019-04-24 17:08:15 +08:00
|
|
|
changed_when: false
|
|
|
|
when: check_existing_cephfs.rc != 0
|
2018-06-29 17:48:01 +08:00
|
|
|
|
2018-05-23 11:07:38 +08:00
|
|
|
- name: set max_mds
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs set {{ cephfs }} max_mds {{ mds_max_mds }}"
|
2018-05-23 11:07:38 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-10-11 01:09:49 +08:00
|
|
|
when:
|
|
|
|
- mds_max_mds > 1
|
|
|
|
- not rolling_update
|