2015-01-30 20:34:35 +08:00
|
|
|
---
|
2018-06-01 16:38:46 +08:00
|
|
|
- name: wait for all osd to be up
|
|
|
|
shell: >
|
2019-05-14 20:51:32 +08:00
|
|
|
test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" -gt 0 &&
|
|
|
|
test "$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_osds"])')" =
|
|
|
|
"$({{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["osdmap"]["osdmap"]["num_up_osds"])')"
|
2018-06-01 16:38:46 +08:00
|
|
|
register: wait_for_all_osds_up
|
2019-02-20 23:24:25 +08:00
|
|
|
retries: "{{ nb_retry_wait_osd_up }}"
|
|
|
|
delay: "{{ delay_wait_osd_up }}"
|
2018-10-30 22:51:32 +08:00
|
|
|
changed_when: false
|
2018-06-01 16:38:46 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
until: wait_for_all_osds_up.rc == 0
|
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: pool related tasks
|
|
|
|
block:
|
|
|
|
- name: list existing pool(s)
|
|
|
|
command: >
|
2019-05-14 20:51:32 +08:00
|
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
2018-10-01 23:11:13 +08:00
|
|
|
osd pool get {{ item.name }} size
|
|
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
|
|
register: created_pools
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-07-23 04:58:40 +08:00
|
|
|
failed_when: created_pools.rc in [1, 125]
|
|
|
|
changed_when: false
|
2018-04-27 20:48:33 +08:00
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: create openstack pool(s)
|
|
|
|
command: >
|
2019-05-14 20:51:32 +08:00
|
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
2018-10-01 23:11:13 +08:00
|
|
|
osd pool create {{ item.0.name }}
|
2018-11-13 22:40:35 +08:00
|
|
|
{{ item.0.pg_num | default(osd_pool_default_pg_num) }}
|
|
|
|
{{ item.0.pgp_num | default(item.0.pg_num) | default(osd_pool_default_pg_num) }}
|
2018-11-01 23:03:16 +08:00
|
|
|
{{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }}
|
2018-10-01 23:11:13 +08:00
|
|
|
{{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
|
2018-11-01 23:03:16 +08:00
|
|
|
{%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %}
|
2018-10-01 23:11:13 +08:00
|
|
|
{{ item.0.erasure_profile }}
|
|
|
|
{%- endif %}
|
|
|
|
{{ item.0.expected_num_objects | default('') }}
|
|
|
|
with_together:
|
|
|
|
- "{{ openstack_pools | unique }}"
|
|
|
|
- "{{ created_pools.results }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: item.1.get('rc', 0) != 0
|
2015-01-30 20:34:35 +08:00
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: customize pool size
|
|
|
|
command: >
|
2019-05-14 20:51:32 +08:00
|
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
2018-11-21 18:00:11 +08:00
|
|
|
osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}
|
2018-10-01 23:11:13 +08:00
|
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2019-04-01 23:46:15 +08:00
|
|
|
when: item.size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|
2018-10-01 23:11:13 +08:00
|
|
|
|
2019-03-01 04:58:31 +08:00
|
|
|
- name: customize pool min_size
|
|
|
|
command: >
|
2019-05-14 20:51:32 +08:00
|
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
2019-03-01 04:58:31 +08:00
|
|
|
osd pool set {{ item.name }} min_size {{ item.min_size | default(osd_pool_default_min_size) }}
|
|
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2019-04-01 23:46:15 +08:00
|
|
|
when: (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-10-01 23:11:13 +08:00
|
|
|
- name: assign application to pool(s)
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} {{ item.application }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: item.application is defined
|
2018-02-09 22:12:35 +08:00
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
- name: create openstack cephx key(s)
|
|
|
|
ceph_key:
|
|
|
|
state: present
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
secret: "{{ item.key | default('') }}"
|
|
|
|
cluster: "{{ cluster }}"
|
2018-04-20 22:37:05 +08:00
|
|
|
mode: "{{ item.mode|default(omit) }}"
|
2018-11-18 23:10:11 +08:00
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2016-09-21 20:21:41 +08:00
|
|
|
with_items: "{{ openstack_keys }}"
|
2018-05-22 22:41:40 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-05-22 16:02:42 +08:00
|
|
|
when: cephx | bool
|
2017-06-23 18:35:39 +08:00
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
- name: fetch openstack cephx key(s)
|
2017-07-19 05:11:55 +08:00
|
|
|
fetch:
|
|
|
|
src: "/etc/ceph/{{ cluster }}.{{ item.name }}.keyring"
|
|
|
|
dest: "{{ fetch_directory }}/{{ fsid }}/etc/ceph/{{ cluster }}.{{ item.name }}.keyring"
|
|
|
|
flat: yes
|
2018-05-22 22:41:40 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2017-07-19 05:11:55 +08:00
|
|
|
with_items: "{{ openstack_keys }}"
|
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
- name: copy to other mons the openstack cephx key(s)
|
2017-07-19 05:11:55 +08:00
|
|
|
copy:
|
2019-03-01 23:41:55 +08:00
|
|
|
src: "{{ fetch_directory }}/{{ fsid }}/etc/ceph/{{ cluster }}.{{ item.1.name }}.keyring"
|
2017-07-19 05:11:55 +08:00
|
|
|
dest: "/etc/ceph/{{ cluster }}.{{ item.1.name }}.keyring"
|
2018-04-23 16:02:16 +08:00
|
|
|
owner: "{{ ceph_uid }}"
|
|
|
|
group: "{{ ceph_uid }}"
|
|
|
|
mode: "{{ item.1.mode|default(omit) }}"
|
2017-07-19 05:11:55 +08:00
|
|
|
with_nested:
|
|
|
|
- "{{ groups[mon_group_name] }}"
|
|
|
|
- "{{ openstack_keys }}"
|
|
|
|
delegate_to: "{{ item.0 }}"
|
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- cephx | bool
|
|
|
|
- openstack_config | bool
|
2019-04-01 23:46:15 +08:00
|
|
|
- item.0 != groups[mon_group_name]
|