2015-01-30 20:34:35 +08:00
|
|
|
---
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: pool related tasks
|
|
|
|
block:
|
|
|
|
- name: list existing pool(s)
|
|
|
|
command: >
|
2020-01-27 20:31:29 +08:00
|
|
|
{{ hostvars[groups[mon_group_name][0]]['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: >
|
2020-01-27 20:31:29 +08:00
|
|
|
{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }}
|
2018-10-01 23:11:13 +08:00
|
|
|
osd pool create {{ item.0.name }}
|
2020-02-28 23:03:15 +08:00
|
|
|
{{ item.0.pg_num | default(osd_pool_default_pg_num) if not item.0.pg_autoscale_mode | default(False) | bool else 16 }}
|
|
|
|
{{ item.0.pgp_num | default(item.0.pg_num) | default(osd_pool_default_pg_num) if not item.0.pg_autoscale_mode | default(False) | bool else '' }}
|
2020-02-28 18:41:00 +08:00
|
|
|
{%- if item.0.type | default(1) | int == 1 or item.0.type | default('replicated') == 'replicated' %}
|
|
|
|
replicated
|
2020-03-27 23:21:09 +08:00
|
|
|
{{ item.0.rule_name | default(ceph_osd_pool_default_crush_rule_name) }}
|
2020-02-28 23:03:15 +08:00
|
|
|
{{ item.0.expected_num_objects | default(0) }}
|
2020-02-28 18:41:00 +08:00
|
|
|
{%- else %}
|
|
|
|
erasure
|
2018-10-01 23:11:13 +08:00
|
|
|
{{ item.0.erasure_profile }}
|
|
|
|
{%- endif %}
|
|
|
|
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
|
|
|
|
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: "{{ openstack_pools | unique }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2020-05-14 17:00:12 +08:00
|
|
|
when:
|
|
|
|
- item.pg_autoscale_mode | default(False) | bool
|
|
|
|
- item.target_size_ratio is defined
|
2020-02-28 23:03:15 +08:00
|
|
|
|
|
|
|
- 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: "{{ openstack_pools | unique }}"
|
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: customize pool size
|
|
|
|
command: >
|
2020-01-27 20:31:29 +08:00
|
|
|
{{ hostvars[groups[mon_group_name][0]]['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
|
2020-03-03 17:47:19 +08:00
|
|
|
when:
|
|
|
|
- item.size | default(osd_pool_default_size)
|
|
|
|
- item.type | default(1) | int != 3
|
|
|
|
- item.type | default('replicated') != 'erasure'
|
2018-10-01 23:11:13 +08:00
|
|
|
|
2019-03-01 04:58:31 +08:00
|
|
|
- name: customize pool min_size
|
|
|
|
command: >
|
2020-01-27 20:31:29 +08:00
|
|
|
{{ hostvars[groups[mon_group_name][0]]['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
|
2020-03-03 17:47:19 +08:00
|
|
|
when:
|
|
|
|
- (item.min_size | default(osd_pool_default_min_size))|int > ceph_osd_pool_default_min_size
|
|
|
|
- item.type | default(1) | int != 3
|
|
|
|
- item.type | default('replicated') != 'erasure'
|
2019-03-01 04:58:31 +08:00
|
|
|
|
2020-08-18 03:27:16 +08:00
|
|
|
- name: customize pool crush_rule
|
|
|
|
command: >
|
|
|
|
{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }}
|
|
|
|
osd pool set {{ item.name }} crush_rule {{ item.rule_name | default(ceph_osd_pool_default_crush_rule_name) }}
|
|
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
- item.rule_name | default(ceph_osd_pool_default_crush_rule_name)
|
|
|
|
- item.type | default(1) | int != 3
|
|
|
|
- item.type | default('replicated') != 'erasure'
|
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: assign application to pool(s)
|
2020-01-27 20:31:29 +08:00
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['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)
|
2019-09-23 19:30:05 +08:00
|
|
|
block:
|
|
|
|
- name: generate keys
|
|
|
|
ceph_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
caps: "{{ item.caps }}"
|
|
|
|
secret: "{{ item.key | default('') }}"
|
|
|
|
cluster: "{{ cluster }}"
|
2020-11-02 22:56:28 +08:00
|
|
|
mode: "{{ item.mode | default(ceph_keyring_permissions) }}"
|
2019-09-23 19:30:05 +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 }}"
|
|
|
|
with_items: "{{ openstack_keys }}"
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2017-06-23 18:35:39 +08:00
|
|
|
|
2019-09-23 19:30:05 +08:00
|
|
|
- name: get keys from monitors
|
2020-01-27 20:31:29 +08:00
|
|
|
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} auth get {{ item.name }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
register: _osp_keys
|
|
|
|
with_items: "{{ openstack_keys }}"
|
2019-10-02 15:57:50 +08:00
|
|
|
run_once: true
|
2019-09-23 19:30:05 +08:00
|
|
|
delegate_to: "{{ groups.get(mon_group_name)[0] }}"
|
2017-07-19 05:11:55 +08:00
|
|
|
|
2019-09-23 19:30:05 +08:00
|
|
|
- name: copy ceph key(s) if needed
|
|
|
|
copy:
|
|
|
|
dest: "/etc/ceph/{{ cluster }}.{{ item.0.item.name }}.keyring"
|
|
|
|
content: "{{ item.0.stdout + '\n' }}"
|
2020-08-10 17:52:56 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
mode: "{{ item.0.item.mode | default(ceph_keyring_permissions) }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
with_nested:
|
|
|
|
- "{{ _osp_keys.results }}"
|
|
|
|
- "{{ groups[mon_group_name] }}"
|
|
|
|
delegate_to: "{{ item.1 }}"
|
2017-07-19 05:11:55 +08:00
|
|
|
when:
|
2019-05-22 16:02:42 +08:00
|
|
|
- cephx | bool
|
|
|
|
- openstack_config | bool
|