2018-05-23 11:07:38 +08:00
|
|
|
---
|
2019-02-12 11:15:44 +08:00
|
|
|
- name: compile a list of pool names
|
|
|
|
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] }}"
|
|
|
|
block:
|
|
|
|
- name: get and store list of filesystem pools
|
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls"
|
|
|
|
changed_when: false
|
|
|
|
register: osd_pool_ls
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
|
- name: deploy filesystem pools
|
|
|
|
when: fs_pools_created is not defined
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
block:
|
|
|
|
- name: create filesystem pools
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool create {{ item.name }} {{ item.pgs | default(osd_pool_default_pg_num) }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
changed_when: false
|
2019-02-12 11:15:44 +08:00
|
|
|
with_items: "{{ cephfs_pools }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
|
|
|
|
- name: customize pool size
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
with_items: "{{ cephfs_pools | unique }}"
|
|
|
|
changed_when: false
|
2018-11-21 18:00:11 +08:00
|
|
|
when:
|
|
|
|
- item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|
2018-05-23 11:07:38 +08:00
|
|
|
|
2019-03-01 04:58:31 +08:00
|
|
|
- name: customize pool min_size
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ item.name }} min_size {{ item.min_size | default(osd_pool_default_min_size) }}"
|
2019-03-01 04:58:31 +08:00
|
|
|
with_items: "{{ cephfs_pools | unique }}"
|
|
|
|
changed_when: false
|
|
|
|
when:
|
2019-03-06 03:17:11 +08:00
|
|
|
- (item.min_size | default(osd_pool_default_min_size))|int > ceph_osd_pool_default_min_size
|
2019-03-01 04:58:31 +08:00
|
|
|
|
2018-05-23 11:07:38 +08:00
|
|
|
- name: check if ceph filesystem already exists
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}"
|
2018-05-23 11:07:38 +08:00
|
|
|
register: check_existing_cephfs
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2019-02-12 11:15:44 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2018-05-23 11:07:38 +08:00
|
|
|
|
|
|
|
- name: create ceph filesystem
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}"
|
2018-05-23 11:07:38 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- check_existing_cephfs.rc != 0
|
|
|
|
|
2018-06-29 17:48:01 +08:00
|
|
|
- name: assign application to cephfs pools
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item }} {{ cephfs }}"
|
2018-06-29 17:48:01 +08:00
|
|
|
with_items:
|
|
|
|
- "{{ cephfs_data }}"
|
|
|
|
- "{{ cephfs_metadata }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- check_existing_cephfs.rc != 0
|
|
|
|
|
2018-05-23 11:07:38 +08:00
|
|
|
- name: allow multimds
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} fs set {{ cephfs }} allow_multimds true --yes-i-really-mean-it"
|
2018-05-23 11:07:38 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
2018-06-05 03:52:47 +08:00
|
|
|
- ceph_release_num[ceph_release] == ceph_release_num.luminous
|
2018-05-23 11:07:38 +08:00
|
|
|
|
|
|
|
- name: set max_mds
|
2019-02-12 11:15:44 +08:00
|
|
|
command: "{{ docker_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] }}"
|
|
|
|
when:
|
|
|
|
- mds_max_mds > 1
|