osd: ceph-volume activate, just pass the OSD_ID

We don't need to pass the device and discover the OSD ID. We have a
task that gathers all the OSD ID present on that machine, so we simply
re-use them and activate them. This also handles the situation when you
have multiple OSDs running on the same device.

Signed-off-by: Sébastien Han <seb@redhat.com>
pull/3220/head
Sébastien Han 2018-09-28 18:07:08 +02:00 committed by Guillaume Abrioux
parent 5f35910ee1
commit a948677de1
1 changed files with 6 additions and 16 deletions

View File

@ -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}" \