ceph-ansible/roles/ceph-osd/templates/ceph-osd-run.sh.j2

57 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# {{ ansible_managed }}
#############
# FUNCTIONS #
#############
function create_dev_list {
local regex
local disks
regex="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
# we use the prepare container to find the partitions to expose
disks=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep -Eo /dev/disk/by-partuuid/${regex} | uniq)
for disk in $disks; do
DEVICES="--device $disk "
done
}
create_dev_list $1
########
# MAIN #
########
/usr/bin/docker run \
--rm \
--net=host \
--privileged=true \
{% if ansible_distribution == 'Ubuntu' -%}
--security-opt apparmor:unconfined \
{% endif -%}
--pid=host \
{% if not containerized_deployment_with_kv -%}
-v /var/lib/ceph:/var/lib/ceph \
-v /etc/ceph:/etc/ceph \
{% else -%}
-e KV_TYPE={{kv_type}} \
-e KV_IP={{kv_endpoint}} \
-e KV_PORT={{kv_port}} \
{% endif -%}
-v /dev:/dev \
-v /etc/localtime:/etc/localtime:ro \
--device=/dev/${1} \
--device=/dev/${1}1 \
{% if dedicated_devices|length > 0 -%}
-e OSD_JOURNAL={{ dedicated_devices[0] }} \
{% else -%}
--device=/dev/${1}2 \
{% endif -%}
-e OSD_DEVICE=/dev/${1} \
{{ ceph_osd_docker_extra_env }} \
--name=ceph-osd-{{ ansible_hostname }}-dev${1} \
-e CEPH_DAEMON=OSD_CEPH_DISK_ACTIVATE \
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}