ceph-ansible/roles/ceph-osd/tasks/activate_osds.yml

38 lines
1.3 KiB
YAML

---
# NOTE (leseb) : this task is for disk devices only because of the explicit use of the first
# partition.
- name: activate osd(s) when device is a disk
command: ceph-disk activate "{{ item }}{%- if 'nvme' in item or 'cciss' in item or 'loop' in item %}{{ 'p' }}{%- endif %}{{ '1' }}"
with_items:
- "{{ devices|unique }}"
changed_when: false
register: activate_osd_disk
when:
- not osd_auto_discovery
- not dmcrypt
- name: activate osd(s) when device is a disk (dmcrypt)
command: ceph-disk activate --dmcrypt "{{ item }}{%- if 'nvme' in item or 'cciss' in item or 'loop' in item %}{{ 'p' }}{%- endif %}{{ '1' }}"
with_items:
- "{{ devices|unique }}"
changed_when: false
register: activate_osd_disk_dmcrypt
when:
- not osd_auto_discovery
- dmcrypt
# NOTE (leseb): we must do this because of
# https://github.com/ansible/ansible/issues/4297
- name: set_fact combined_activate_osd_disk_results
set_fact:
combined_activate_osd_disk_results: "{{ activate_osd_disk if osd_scenario != 'collocated' else activate_osd_disk_dmcrypt }}"
- name: fail if ceph-disk cannot create an OSD
fail:
msg: "ceph-disk failed to create an OSD"
when:
" 'ceph-disk: Error: ceph osd create failed' in item.get('stderr', '') "
with_items: "{{ (combined_activate_osd_disk_results|default({})).results|default([]) }}"