2017-02-08 05:00:53 +08:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
2017-06-26 21:40:30 +08:00
|
|
|
|
|
2017-07-25 23:54:26 +08:00
|
|
|
|
#############
|
|
|
|
|
# VARIABLES #
|
|
|
|
|
#############
|
|
|
|
|
|
|
|
|
|
REGEX="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
|
|
|
|
|
|
|
|
|
|
|
2017-06-26 21:40:30 +08:00
|
|
|
|
#############
|
|
|
|
|
# FUNCTIONS #
|
|
|
|
|
#############
|
|
|
|
|
|
2017-07-25 23:54:26 +08:00
|
|
|
|
|
|
|
|
|
function expose_devices {
|
2017-06-26 21:40:30 +08:00
|
|
|
|
local disks
|
|
|
|
|
# we use the prepare container to find the partitions to expose
|
2017-07-25 23:54:26 +08:00
|
|
|
|
disks=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
2017-06-26 21:40:30 +08:00
|
|
|
|
for disk in $disks; do
|
2017-07-25 23:54:26 +08:00
|
|
|
|
DEVICES="--device=$disk "
|
2017-02-08 05:00:53 +08:00
|
|
|
|
done
|
2017-06-26 21:40:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-25 23:54:26 +08:00
|
|
|
|
function expose_partitions {
|
|
|
|
|
local partition
|
|
|
|
|
for partition in Block.wal Block.db Journal; do
|
|
|
|
|
if docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep -Eo "$partition is GPT partition"; then
|
|
|
|
|
if [[ "$partition" == "Block.wal" ]]; then
|
|
|
|
|
part=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep "$partition is GPT partition" | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
|
|
|
|
DOCKER_ENV="$DOCKER_ENV -e OSD_BLUESTORE_BLOCK_WAL=$part"
|
|
|
|
|
elif [[ "$partition" == "Block.db" ]]; then
|
|
|
|
|
part=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep "$partition is GPT partition" | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
|
|
|
|
DOCKER_ENV="$DOCKER_ENV -e OSD_BLUESTORE_BLOCK_DB=$part"
|
|
|
|
|
elif [[ "$partition" == "Journal" ]]; then
|
|
|
|
|
part=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep "$partition is GPT partition" | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
|
|
|
|
DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#expose_devices $1
|
|
|
|
|
expose_partitions $1
|
2017-06-26 21:40:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########
|
|
|
|
|
# MAIN #
|
|
|
|
|
########
|
2017-02-08 05:00:53 +08:00
|
|
|
|
|
|
|
|
|
/usr/bin/docker run \
|
|
|
|
|
--rm \
|
|
|
|
|
--net=host \
|
2017-06-26 21:40:30 +08:00
|
|
|
|
--privileged=true \
|
2017-07-25 23:54:26 +08:00
|
|
|
|
--pid=host \
|
2017-09-06 16:53:30 +08:00
|
|
|
|
--memory={{ ceph_osd_docker_memory_limit }} \
|
|
|
|
|
{% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
|
|
|
|
|
--cpus={{ ceph_osd_docker_cpu_limit }} \
|
|
|
|
|
{% else -%}
|
|
|
|
|
--cpu-quota={{ ceph_osd_docker_cpu_limit * 100000 }} \
|
|
|
|
|
{% endif -%}
|
2017-07-25 23:54:26 +08:00
|
|
|
|
-v /dev:/dev \
|
|
|
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
|
|
|
-v /var/lib/ceph:/var/lib/ceph \
|
|
|
|
|
-v /etc/ceph:/etc/ceph \
|
|
|
|
|
$DOCKER_ENV \
|
2017-04-19 17:12:04 +08:00
|
|
|
|
{% if ansible_distribution == 'Ubuntu' -%}
|
|
|
|
|
--security-opt apparmor:unconfined \
|
|
|
|
|
{% endif -%}
|
2017-04-13 01:57:33 +08:00
|
|
|
|
{% if not containerized_deployment_with_kv -%}
|
2017-02-08 05:00:53 +08:00
|
|
|
|
{% else -%}
|
2017-07-25 23:54:26 +08:00
|
|
|
|
-e KV_TYPE={{ kv_type }} \
|
|
|
|
|
-e KV_IP={{ kv_endpoint }} \
|
|
|
|
|
-e KV_PORT={{ kv_port }} \
|
2017-02-08 05:00:53 +08:00
|
|
|
|
{% endif -%}
|
2017-07-25 23:54:26 +08:00
|
|
|
|
{% if osd_objectstore == 'filestore' and not dmcrypt -%}
|
|
|
|
|
-e OSD_FILESTORE=1 \
|
|
|
|
|
-e OSD_DMCRYPT=0 \
|
|
|
|
|
{% endif -%}
|
|
|
|
|
{% if osd_objectstore == 'filestore' and dmcrypt -%}
|
|
|
|
|
-e OSD_FILESTORE=1 \
|
|
|
|
|
-e OSD_DMCRYPT=1 \
|
|
|
|
|
{% endif -%}
|
|
|
|
|
{% if osd_objectstore == 'bluestore' and not dmcrypt -%}
|
|
|
|
|
-e OSD_BLUESTORE=1 \
|
|
|
|
|
-e OSD_DMCRYPT=0 \
|
2017-02-08 05:00:53 +08:00
|
|
|
|
{% endif -%}
|
2017-07-25 23:54:26 +08:00
|
|
|
|
{% if osd_objectstore == 'bluestore' and dmcrypt -%}
|
|
|
|
|
-e OSD_BLUESTORE=1 \
|
|
|
|
|
-e OSD_DMCRYPT=1 \
|
|
|
|
|
{% endif -%}
|
|
|
|
|
-e CLUSTER={{ cluster }} \
|
2017-02-08 05:00:53 +08:00
|
|
|
|
-e OSD_DEVICE=/dev/${1} \
|
2017-07-25 23:54:26 +08:00
|
|
|
|
-e CEPH_DAEMON=OSD_CEPH_DISK_ACTIVATE \
|
2017-02-08 05:00:53 +08:00
|
|
|
|
{{ ceph_osd_docker_extra_env }} \
|
2017-02-20 17:03:49 +08:00
|
|
|
|
--name=ceph-osd-{{ ansible_hostname }}-dev${1} \
|
2017-02-08 05:00:53 +08:00
|
|
|
|
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
|