diff --git a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 index b549c8f1f..ad55ea38c 100644 --- a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 +++ b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 @@ -2,17 +2,16 @@ # {{ ansible_managed }} +{% if osd_scenario != 'lvm' -%} +{% if disk_list.get('rc') == 0 -%} ############# # VARIABLES # ############# DOCKER_ENV="" - ############# # FUNCTIONS # ############# -{% if osd_scenario != 'lvm' -%} -{% if disk_list.get('rc') == 0 -%} function expose_partitions () { DOCKER_ENV=$(docker run --rm --net=host --name expose_partitions_${1} --privileged=true -v /dev/:/dev/ -v /etc/ceph:/etc/ceph:z -e CLUSTER={{ cluster }} -e OSD_DEVICE=/dev/${1} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} disk_list) } @@ -52,19 +51,10 @@ function expose_partitions { exit 1 fi } -{% endif -%} -{% endif -%} expose_partitions "$1" -{% if osd_scenario == 'lvm' -%} -function find_device_from_id { - OSD_ID="$1" - LV=$(docker run --privileged=true -v /dev:/dev -v /run/lvm/lvmetad.socket:/run/lvm/lvmetad.socket -v /etc/ceph:/etc/ceph:z --entrypoint=ceph-volume {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} lvm list --format json | python -c "import sys, json; print(json.load(sys.stdin)[\"$OSD_ID\"][0][\"path\"])") - OSD_DEVICE=$(lvdisplay -m $LV | awk '/Physical volume/ {print $3}') -} - -find_device_from_id $@ +{% endif -%} {% endif -%} @@ -94,7 +84,6 @@ find_device_from_id $@ -v /var/lib/ceph:/var/lib/ceph:z \ -v /etc/ceph:/etc/ceph:z \ -v /var/run/ceph:/var/run/ceph:z \ - $DOCKER_ENV \ {% if ansible_distribution == 'Ubuntu' -%} --security-opt apparmor:unconfined \ {% endif -%} @@ -126,9 +115,10 @@ find_device_from_id $@ {% if osd_scenario == 'lvm' -%} -v /run/lvm/lvmetad.socket:/run/lvm/lvmetad.socket \ -e CEPH_DAEMON=OSD_CEPH_VOLUME_ACTIVATE \ - -e OSD_DEVICE="$OSD_DEVICE" \ - --name=ceph-osd-"$OSD_ID" \ + -e OSD_ID="$1" \ + --name=ceph-osd-"$1" \ {% else -%} + $DOCKER_ENV \ -e CEPH_DAEMON=OSD_CEPH_DISK_ACTIVATE \ -e OSD_DEVICE=/dev/"${1}" \ --name=ceph-osd-{{ ansible_hostname }}-"${1}" \