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

102 lines
3.2 KiB
YAML
Raw Normal View History

2014-09-05 03:14:11 +08:00
---
# NOTE (leseb) : this task is for disk devices only because of the explicit use of the first
2014-09-05 03:14:11 +08:00
# partition.
- name: automatically activate osd disk(s) without partitions
command: ceph-disk activate "/dev/{{ item.key | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1"
ignore_errors: true
with_dict: "{{ ansible_devices }}"
when:
- ansible_devices is defined
- item.value.removable == "0"
- item.value.partitions|count == 0
- item.value.holders|count == 0
- osd_scenario == 'collocated'
- osd_auto_discovery
- name: activate osd(s) when device is a disk
2015-10-19 09:24:47 +08:00
command: ceph-disk activate {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
2014-09-05 03:14:11 +08:00
with_together:
- "{{ ispartition_results.results }}"
- "{{ devices|unique }}"
changed_when: false
failed_when: false
register: activate_osd_disk
when:
- not item.0.get("skipped")
- item.0.get("rc", 0) != 0
- not osd_auto_discovery
- osd_scenario == 'non-collocated'
- name: automatically activate osd disk(s) without partitions (dmcrypt)
command: ceph-disk activate --dmcrypt "/dev/{{ item.key }}"
ignore_errors: true
with_dict: "{{ ansible_devices }}"
when:
- ansible_devices is defined
- item.value.removable == "0"
- item.value.partitions|count == 0
- item.value.holders|count == 0
- osd_auto_discovery
- dmcrypt
- osd_scenario == 'collocated'
- name: activate osd(s) when device is a disk (dmcrypt)
command: ceph-disk activate --dmcrypt {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
with_together:
- "{{ ispartition_results.results }}"
- "{{ devices|unique }}"
changed_when: false
failed_when: false
register: activate_osd_disk_dmcrypt
when:
- not item.0.get("skipped")
- item.0.get("rc", 0) != 0
- not osd_auto_discovery
- dmcrypt
- osd_scenario == 'non-collocated'
# NOTE (leseb): we must do this because of
# https://github.com/ansible/ansible/issues/4297
- name: combine ispartition results
set_fact:
combined_activate_osd_disk_results: "{{ activate_osd_disk if osd_scenario != 'collocated' else activate_osd_disk_dmcrypt }}"
2014-09-05 03:14:11 +08:00
- 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([]) }}"
# NOTE (leseb): this task is for partitions because we don't explicitly use a partition.
- name: activate osd(s) when device is a partition
2014-09-05 03:14:11 +08:00
command: "ceph-disk activate {{ item.1 }}"
with_together:
- "{{ ispartition_results.results }}"
- "{{ devices|unique }}"
changed_when: false
failed_when: false
when:
- not item.0.get("skipped")
- item.0.get("rc", 0) == 0
- not osd_auto_discovery
2014-09-05 03:14:11 +08:00
- include: osd_fragment.yml
when: crush_location
- name: get osd id
shell: |
ls /var/lib/ceph/osd/ | sed 's/.*-//'
changed_when: false
failed_when: false
always_run: true
register: osd_id
- name: start and add that the osd service(s) to the init sequence
service:
name: ceph-osd@{{ item }}
state: started
with_items: "{{ (osd_id|default({})).stdout_lines|default([]) }}"
changed_when: false