]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
osd: ceph-volume activate, just pass the OSD_ID
authorSébastien Han <seb@redhat.com>
Fri, 28 Sep 2018 16:07:08 +0000 (18:07 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Wed, 10 Oct 2018 20:08:41 +0000 (16:08 -0400)
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>
roles/ceph-osd/templates/ceph-osd-run.sh.j2

index b549c8f1f5178d1dfdbaf844bcad047d5b500395..ad55ea38cfb68b8ee733140adcfad2120fcacff4 100644 (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}" \