mirror of https://github.com/ceph/ceph-ansible.git
95 lines
4.0 KiB
YAML
95 lines
4.0 KiB
YAML
---
|
|
- name: pool related tasks
|
|
block:
|
|
- name: list existing pool(s)
|
|
command: >
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
|
osd pool get {{ item.name }} size
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
register: created_pools
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
failed_when: created_pools.rc in [1, 125]
|
|
changed_when: false
|
|
|
|
- name: create openstack pool(s)
|
|
command: >
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
|
osd pool create {{ item.0.name }}
|
|
{{ 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) }}
|
|
{{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }}
|
|
{{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }}
|
|
{%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %}
|
|
{{ 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] }}"
|
|
when: item.1.get('rc', 0) != 0
|
|
|
|
- name: customize pool size
|
|
command: >
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
|
osd pool set {{ item.name }} size {{ item.size | default(osd_pool_default_size) }}
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
changed_when: false
|
|
when: item.size | default(osd_pool_default_size)
|
|
|
|
- name: customize pool min_size
|
|
command: >
|
|
{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }}
|
|
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
|
|
when: (item.min_size | default(osd_pool_default_min_size))|int > ceph_osd_pool_default_min_size
|
|
|
|
- name: assign application to pool(s)
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} {{ item.application }}"
|
|
with_items: "{{ openstack_pools | unique }}"
|
|
changed_when: false
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
when: item.application is defined
|
|
|
|
- name: create openstack cephx key(s)
|
|
block:
|
|
- name: generate keys
|
|
ceph_key:
|
|
state: present
|
|
name: "{{ item.name }}"
|
|
caps: "{{ item.caps }}"
|
|
secret: "{{ item.key | default('') }}"
|
|
cluster: "{{ cluster }}"
|
|
mode: "{{ item.mode|default(omit) }}"
|
|
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] }}"
|
|
|
|
- name: get keys from monitors
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} auth get {{ item.name }}"
|
|
register: _osp_keys
|
|
with_items: "{{ openstack_keys }}"
|
|
run_once: true
|
|
delegate_to: "{{ groups.get(mon_group_name)[0] }}"
|
|
|
|
- name: copy ceph key(s) if needed
|
|
copy:
|
|
dest: "/etc/ceph/{{ cluster }}.{{ item.0.item.name }}.keyring"
|
|
content: "{{ item.0.stdout + '\n' }}"
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
mode: "{{ item.0.item.mode }}"
|
|
with_nested:
|
|
- "{{ _osp_keys.results }}"
|
|
- "{{ groups[mon_group_name] }}"
|
|
delegate_to: "{{ item.1 }}"
|
|
when:
|
|
- cephx | bool
|
|
- openstack_config | bool
|