2017-02-08 05:00:53 +08:00
|
|
|
# {{ ansible_managed }}
|
2016-02-11 02:15:52 +08:00
|
|
|
[Unit]
|
|
|
|
Description=Ceph OSD
|
2019-03-08 01:31:39 +08:00
|
|
|
{% if container_binary == 'docker' %}
|
2016-02-11 02:15:52 +08:00
|
|
|
After=docker.service
|
2020-06-23 01:58:10 +08:00
|
|
|
Requires=docker.service
|
2019-06-07 03:41:35 +08:00
|
|
|
{% else %}
|
|
|
|
After=network.target
|
2019-03-08 01:31:39 +08:00
|
|
|
{% endif %}
|
2020-06-10 03:19:57 +08:00
|
|
|
{% set cpu_limit = ansible_processor_vcpus|int if ceph_osd_docker_cpu_limit|int > ansible_processor_vcpus|int else ceph_osd_docker_cpu_limit|int %}
|
2016-02-11 02:15:52 +08:00
|
|
|
|
|
|
|
[Service]
|
2016-03-29 16:23:31 +08:00
|
|
|
EnvironmentFile=-/etc/environment
|
2020-06-23 00:58:56 +08:00
|
|
|
{% if container_binary == 'podman' %}
|
|
|
|
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
|
|
|
|
{% else %}
|
2018-11-08 17:02:37 +08:00
|
|
|
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
|
|
|
|
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i
|
2020-06-23 00:58:56 +08:00
|
|
|
{% endif %}
|
2020-06-10 03:19:57 +08:00
|
|
|
ExecStart={% if ceph_osd_numactl_opts != "" %}
|
|
|
|
numactl \
|
|
|
|
{{ ceph_osd_numactl_opts }} \
|
|
|
|
{% endif %}
|
|
|
|
/usr/bin/{{ container_binary }} run \
|
2020-06-23 00:58:56 +08:00
|
|
|
{% if container_binary == 'podman' %}
|
|
|
|
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \
|
|
|
|
{% endif %}
|
2020-06-10 03:19:57 +08:00
|
|
|
--rm \
|
|
|
|
--net=host \
|
|
|
|
--privileged=true \
|
|
|
|
--pid=host \
|
|
|
|
--ipc=host \
|
|
|
|
{% if osd_objectstore == 'filestore' -%}
|
|
|
|
--memory={{ ceph_osd_docker_memory_limit }} \
|
|
|
|
{% endif -%}
|
|
|
|
{% if (container_binary == 'docker' and ceph_docker_version.split('.')[0] is version('13', '>=')) or container_binary == 'podman' -%}
|
|
|
|
--cpus={{ cpu_limit }} \
|
|
|
|
{% else -%}
|
|
|
|
--cpu-quota={{ cpu_limit * 100000 }} \
|
|
|
|
{% endif -%}
|
|
|
|
{% if ceph_osd_docker_cpuset_cpus is defined -%}
|
|
|
|
--cpuset-cpus='{{ ceph_osd_docker_cpuset_cpus }}' \
|
|
|
|
{% endif -%}
|
|
|
|
{% if ceph_osd_docker_cpuset_mems is defined -%}
|
|
|
|
--cpuset-mems='{{ ceph_osd_docker_cpuset_mems }}' \
|
|
|
|
{% endif -%}
|
|
|
|
-v /dev:/dev \
|
|
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
|
|
-v /var/lib/ceph:/var/lib/ceph:z \
|
|
|
|
-v /etc/ceph:/etc/ceph:z \
|
|
|
|
-v /var/run/ceph:/var/run/ceph:z \
|
|
|
|
-v /var/run/udev/:/var/run/udev/ \
|
|
|
|
-v /var/log/ceph:/var/log/ceph:z \
|
|
|
|
{% if ansible_distribution == 'Ubuntu' -%}
|
|
|
|
--security-opt apparmor:unconfined \
|
|
|
|
{% endif -%}
|
|
|
|
{{ container_env_args }} \
|
|
|
|
-e CLUSTER={{ cluster }} \
|
|
|
|
{% 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 -%}
|
|
|
|
-v /run/lvm/:/run/lvm/ \
|
|
|
|
-e CEPH_DAEMON=OSD_CEPH_VOLUME_ACTIVATE \
|
|
|
|
-e CONTAINER_IMAGE={{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} \
|
|
|
|
-e OSD_ID=%i \
|
|
|
|
--name=ceph-osd-%i \
|
|
|
|
{{ ceph_osd_docker_extra_env }} \
|
|
|
|
{{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
|
2020-06-23 00:58:56 +08:00
|
|
|
{% if container_binary == 'podman' %}
|
|
|
|
ExecStop=-/usr/bin/sh -c "/usr/bin/{{ container_binary }} rm -f `cat /%t/%n-cid`"
|
|
|
|
{% else %}
|
2018-11-08 17:02:37 +08:00
|
|
|
ExecStop=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
|
2020-06-23 00:58:56 +08:00
|
|
|
{% endif %}
|
2020-02-11 23:09:51 +08:00
|
|
|
KillMode=none
|
2016-02-11 02:15:52 +08:00
|
|
|
Restart=always
|
|
|
|
RestartSec=10s
|
|
|
|
TimeoutStartSec=120
|
|
|
|
TimeoutStopSec=15
|
2020-06-23 00:58:56 +08:00
|
|
|
{% if container_binary == 'podman' %}
|
|
|
|
Type=forking
|
|
|
|
PIDFile=/%t/%n-pid
|
|
|
|
{% endif %}
|
2016-02-11 02:15:52 +08:00
|
|
|
|
|
|
|
[Install]
|
2016-07-09 09:38:13 +08:00
|
|
|
WantedBy=multi-user.target
|