2017-07-26 05:48:13 +08:00
|
|
|
---
|
2019-03-28 16:13:30 +08:00
|
|
|
- name: container specific tasks
|
2019-04-01 23:46:15 +08:00
|
|
|
when: containerized_deployment
|
2019-03-28 16:13:30 +08:00
|
|
|
block:
|
2018-11-07 18:45:29 +08:00
|
|
|
- name: umount ceph disk (if on openstack)
|
|
|
|
mount:
|
|
|
|
name: /mnt
|
|
|
|
src: /dev/vdb
|
|
|
|
fstype: ext3
|
|
|
|
state: unmounted
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ceph_docker_on_openstack
|
2018-11-07 18:45:29 +08:00
|
|
|
|
|
|
|
- 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"
|
2018-11-08 17:02:37 +08:00
|
|
|
setype: "bin_t"
|
2019-04-01 23:46:15 +08:00
|
|
|
notify: restart ceph osds
|
2018-11-07 18:45:29 +08:00
|
|
|
|
2018-11-29 21:59:25 +08:00
|
|
|
# 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/.*-//'
|
2019-03-01 04:57:03 +08:00
|
|
|
changed_when: false
|
2018-11-29 21:59:25 +08:00
|
|
|
register: osd_ids_non_container
|
|
|
|
|
2018-11-07 18:45:29 +08:00
|
|
|
- name: set_fact docker_exec_start_osd
|
|
|
|
set_fact:
|
2019-02-06 04:28:37 +08:00
|
|
|
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' }}"
|
2018-11-07 18:45:29 +08:00
|
|
|
|
|
|
|
- name: collect osd ids
|
2019-03-02 02:53:03 +08:00
|
|
|
command: "{{ docker_exec_start_osd }} lvm list --format json"
|
2017-07-26 05:48:13 +08:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2018-11-07 18:45:29 +08:00
|
|
|
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"
|
2019-04-01 23:46:15 +08:00
|
|
|
notify: restart ceph osds
|
|
|
|
when: containerized_deployment
|
2018-11-07 18:45:29 +08:00
|
|
|
|
|
|
|
- name: systemd start osd
|
|
|
|
systemd:
|
2019-04-11 16:01:15 +08:00
|
|
|
name: ceph-osd@{{ item }}
|
2018-11-07 18:45:29 +08:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
2019-03-20 18:35:36 +08:00
|
|
|
masked: no
|
2018-11-07 18:45:29 +08:00
|
|
|
daemon_reload: yes
|
2019-04-11 16:01:15 +08:00
|
|
|
with_items: "{{ ((ceph_osd_ids.stdout | from_json).keys() | list) if not containerized_deployment else osd_ids_non_container.stdout_lines }}"
|
2017-07-26 05:48:13 +08:00
|
|
|
|
2017-07-05 21:47:48 +08:00
|
|
|
- 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
|
2018-11-20 07:45:40 +08:00
|
|
|
- ansible_service_mgr == 'systemd'
|