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

101 lines
2.8 KiB
YAML

---
# NOTE (leseb) : this task is for disk devices only because of the explicit use of the first
# partition.
- name: automatically activate osd disk(s) without partitions
command: ceph-disk activate "/dev/{{ item.key }}"
ignore_errors: true
with_dict: ansible_devices
when:
ansible_devices is defined and
item.value.removable == "0" and
item.value.partitions|count == 0 and
journal_collocation and
osd_auto_discovery
- name: activate osd(s) when device is a disk
command: ceph-disk activate {{ item.1 | regex_replace('^(\/dev\/cciss\/c[0-9]{1}d[0-9]{1})$', '\\1p') }}1
with_together:
- combined_ispartition_results.results
- devices
changed_when: false
failed_when: false
register: activate_osd_disk
when:
not item.0.get("skipped") and
item.0.get("rc", 0) != 0 and
not osd_auto_discovery
- 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: "{{activate_osd_disk.results}}"
# NOTE (leseb): this task is for partitions because we don't explicitly use a partition.
- name: activate osd(s) when device is a partition
command: "ceph-disk activate {{ item.1 }}"
with_together:
- combined_ispartition_results.results
- devices
changed_when: false
failed_when: false
when:
not item.0.get("skipped") and
item.0.get("rc", 0) == 0 and
not osd_auto_discovery
- include: osd_fragment.yml
when: crush_location
- name: set selinux to permissive and make it persistent
selinux:
policy: targeted
state: permissive
when:
ansible_selinux != false and
ansible_selinux['status'] == 'enabled' and
ansible_selinux['config_mode'] != 'disabled' and
is_before_infernalis
- name: start and add that the osd service(s) to the init sequence (before infernalis)
service:
name: ceph
state: started
enabled: yes
when:
ansible_distribution != "Ubuntu" and
is_before_infernalis
- name: get osd id (for or after infernalis)
shell: "ls /var/lib/ceph/osd/ | grep '-' | cut -d '-' -f 2"
changed_when: false
failed_when: false
register: osd_id
when:
use_systemd and
is_after_hammer
- name: enable osd service instance(s) (for or after infernalis)
file:
src: /usr/lib/systemd/system/ceph-osd@.service
dest: /etc/systemd/system/multi-user.target.wants/ceph-osd@{{ item }}.service
state: link
with_items: osd_id.stdout_lines
failed_when: false
when:
use_systemd and
is_after_hammer
- name: start and add that the osd service(s) to the init sequence (for or after infernalis)
service:
name: ceph-osd@{{ item }}
state: started
enabled: yes
with_items: osd_id.stdout_lines
changed_when: false
when:
use_systemd and
is_after_hammer