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

70 lines
2.5 KiB
YAML

---
- name: umount ceph disk (if on openstack)
mount:
name: /mnt
src: /dev/vdb
fstype: ext3
state: unmounted
when:
- ceph_docker_on_openstack | bool
- containerized_deployment | bool
# this is for ceph-disk, the ceph-disk command is gone so we have to list /var/lib/ceph
- name: get osd ids
shell: ls /var/lib/ceph/osd/ | sed 's/.*-//' # noqa 306
args:
executable: /bin/bash
changed_when: false
failed_when: false
register: osd_ids_non_container
- name: set_fact docker_exec_start_osd
set_fact:
docker_exec_start_osd: "{{ container_binary + ' run --rm --ulimit nofile=1024:4096 --net=host --privileged=true -v /var/run/udev/:/var/run/udev/:z -v /run/lvm/:/run/lvm/ -v /etc/ceph:/etc/ceph:z -v /dev:/dev --entrypoint=ceph-volume ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph-volume' }}"
- name: collect osd ids
command: "{{ docker_exec_start_osd }} lvm list --format json"
changed_when: false
failed_when: false
register: ceph_osd_ids
- name: include_tasks systemd.yml
include_tasks: systemd.yml
when: containerized_deployment | bool
- name: ensure systemd service override directory exists
file:
state: directory
path: "/etc/systemd/system/ceph-osd@.service.d/"
when:
- ceph_osd_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: add ceph-osd systemd service overrides
config_template:
src: "ceph-osd.service.d-overrides.j2"
dest: "/etc/systemd/system/ceph-osd@.service.d/ceph-osd-systemd-overrides.conf"
config_overrides: "{{ ceph_osd_systemd_overrides | default({}) }}"
config_type: "ini"
when:
- ceph_osd_systemd_overrides is defined
- ansible_facts['service_mgr'] == 'systemd'
- name: ensure "/var/lib/ceph/osd/{{ cluster }}-{{ item }}" is present
file:
state: directory
path: "/var/lib/ceph/osd/{{ cluster }}-{{ item }}"
mode: "{{ ceph_directories_mode }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}') | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
- name: systemd start osd
systemd:
name: ceph-osd@{{ item }}
state: started
enabled: yes
masked: no
daemon_reload: yes
with_items: "{{ ((ceph_osd_ids.stdout | default('{}') | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"