mirror of https://github.com/ceph/ceph-ansible.git
96 lines
3.8 KiB
Django/Jinja
96 lines
3.8 KiB
Django/Jinja
#!/bin/bash
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
#############
|
|
# FUNCTIONS #
|
|
#############
|
|
{% if disk_list.get('rc') == 0 -%}
|
|
function expose_partitions () {
|
|
DOCKER_ENV=$(docker run --rm --name expose_partitions_${1} --privileged=true -v /dev/:/dev/ -v /etc/ceph:/etc/ceph -e CLUSTER={{ cluster }} -e OSD_DEVICE=/dev/${1} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} disk_list)
|
|
docker rm -f expose_partitions_${1}
|
|
}
|
|
{% else -%}
|
|
# NOTE(leseb): maintains backwards compatibility with old ceph-docker Jewel images
|
|
# Jewel images prior to https://github.com/ceph/ceph-docker/pull/797
|
|
REGEX="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
|
|
function expose_partitions {
|
|
if docker ps -a | grep -sq ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}; then
|
|
if [[ ! -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log ]]; then
|
|
docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} &> {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log
|
|
fi
|
|
fi
|
|
if docker ps -a | grep -sq ceph-osd-prepare-{{ ansible_hostname }}-${1}; then
|
|
if [[ ! -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log ]]; then
|
|
docker logs ceph-osd-prepare-{{ ansible_hostname }}-${1} &> {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log
|
|
fi
|
|
fi
|
|
if [[ -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log ]]; then
|
|
part=$(grep "Journal is GPT partition" {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
|
DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part"
|
|
fi
|
|
if [[ -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log ]]; then
|
|
part=$(grep "Journal is GPT partition" {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq)
|
|
DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part"
|
|
fi
|
|
}
|
|
{% endif -%}
|
|
|
|
expose_partitions "$1"
|
|
|
|
|
|
########
|
|
# MAIN #
|
|
########
|
|
|
|
/usr/bin/docker run \
|
|
--rm \
|
|
--net=host \
|
|
--privileged=true \
|
|
--pid=host \
|
|
--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 -%}
|
|
-v /dev:/dev \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v /var/lib/ceph:/var/lib/ceph \
|
|
-v /etc/ceph:/etc/ceph \
|
|
$DOCKER_ENV \
|
|
{% if ansible_distribution == 'Ubuntu' -%}
|
|
--security-opt apparmor:unconfined \
|
|
{% endif -%}
|
|
{% if not containerized_deployment_with_kv -%}
|
|
{% else -%}
|
|
-e KV_TYPE={{ kv_type }} \
|
|
-e KV_IP={{ kv_endpoint }} \
|
|
-e KV_PORT={{ kv_port }} \
|
|
{% endif -%}
|
|
{% 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 \
|
|
{% endif -%}
|
|
{% if osd_objectstore == 'bluestore' and dmcrypt -%}
|
|
-e OSD_BLUESTORE=1 \
|
|
-e OSD_DMCRYPT=1 \
|
|
{% endif -%}
|
|
-e CLUSTER={{ cluster }} \
|
|
-e OSD_DEVICE=/dev/${1} \
|
|
{% if (ceph_tcmalloc_max_total_thread_cache | int) > 0 and osd_objectstore == 'filestore' -%}
|
|
-e TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES={{ ceph_tcmalloc_max_total_thread_cache }} \
|
|
{% endif -%}
|
|
-e CEPH_DAEMON=OSD_CEPH_DISK_ACTIVATE \
|
|
{{ ceph_osd_docker_extra_env }} \
|
|
--name=ceph-osd-{{ ansible_hostname }}-${1} \
|
|
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
|