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

99 lines
3.5 KiB
YAML

---
- name: container specific tasks
when:
- containerized_deployment
block:
- name: umount ceph disk (if on openstack)
mount:
name: /mnt
src: /dev/vdb
fstype: ext3
state: unmounted
when:
- ceph_docker_on_openstack
- name: test if the container image has directory {{ container_bin_path }}
command: "{{ container_binary }} run --rm --net=host --entrypoint=test {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} -d {{ container_bin_path }}"
changed_when: false
failed_when: false
register: test_container_bin_path
when:
- osd_scenario != 'lvm'
- name: test if the container image has the disk_list function
command: "{{ container_binary }} run --rm --net=host --entrypoint=stat {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} {{ container_bin_path + '/disk_list.sh' if test_container_bin_path.rc == 0 else 'disk_list.sh' }}"
changed_when: false
failed_when: false
register: disk_list
when:
- osd_scenario != 'lvm'
- name: generate ceph osd docker run script
become: true
template:
src: "{{ role_path }}/templates/ceph-osd-run.sh.j2"
dest: "{{ ceph_osd_docker_run_script_path }}/ceph-osd-run.sh"
owner: "root"
group: "root"
mode: "0744"
setype: "bin_t"
notify:
- restart ceph osds
# 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/.*-//'
changed_when: false
register: osd_ids_non_container
- name: set_fact docker_exec_start_osd
set_fact:
docker_exec_start_osd: "{{ '{{ container_binary }} run --rm --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 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: generate systemd unit file
become: true
template:
src: "{{ role_path }}/templates/ceph-osd.service.j2"
dest: /etc/systemd/system/ceph-osd@.service
owner: "root"
group: "root"
mode: "0644"
notify:
- restart ceph osds
when:
- containerized_deployment
- name: systemd start osd
systemd:
name: ceph-osd@{{ item | regex_replace('/dev/', '') if osd_scenario != 'lvm' and containerized_deployment else item }}
state: started
enabled: yes
masked: no
daemon_reload: yes
with_items: "{{ devices if osd_scenario != 'lvm' and containerized_deployment else ((ceph_osd_ids.stdout | from_json).keys() | list) if osd_scenario == 'lvm' and not containerized_deployment else osd_ids_non_container.stdout_lines }}"
- 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_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_service_mgr == 'systemd'