2016-01-28 03:50:05 +08:00
|
|
|
[Unit]
|
|
|
|
Description=Ceph Monitor
|
2021-08-10 21:21:19 +08:00
|
|
|
PartOf=ceph-mon.target
|
2019-03-08 01:31:39 +08:00
|
|
|
{% if container_binary == 'docker' %}
|
2021-12-09 00:37:14 +08:00
|
|
|
After=docker.service network-online.target local-fs.target time-sync.target
|
2020-06-23 01:58:10 +08:00
|
|
|
Requires=docker.service
|
2019-06-07 03:41:35 +08:00
|
|
|
{% else %}
|
2021-12-09 00:37:14 +08:00
|
|
|
After=network-online.target local-fs.target time-sync.target
|
2019-03-08 01:31:39 +08:00
|
|
|
{% endif %}
|
2021-12-09 00:37:14 +08:00
|
|
|
Wants=network-online.target local-fs.target time-sync.target
|
2016-01-28 03:50:05 +08:00
|
|
|
|
|
|
|
[Service]
|
2016-03-16 00:32:17 +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
|
2020-11-30 21:52:47 +08:00
|
|
|
ExecStartPre=-/usr/bin/{{ container_binary }} rm --storage ceph-mon-%i
|
2021-04-14 19:41:59 +08:00
|
|
|
ExecStartPre=-/usr/bin/mkdir -p /var/log/ceph
|
2021-01-13 23:17:56 +08:00
|
|
|
{% else %}
|
|
|
|
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mon-%i
|
2020-06-23 00:58:56 +08:00
|
|
|
{% endif %}
|
2020-07-21 21:32:50 +08:00
|
|
|
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i
|
2018-09-06 20:00:13 +08:00
|
|
|
ExecStartPre=/bin/sh -c '"$(command -v mkdir)" -p /etc/ceph /var/lib/ceph/mon'
|
2018-11-08 17:02:37 +08:00
|
|
|
ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-mon-%i \
|
2020-06-23 00:58:56 +08:00
|
|
|
{% if container_binary == 'podman' %}
|
2020-10-22 22:59:15 +08:00
|
|
|
-d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \
|
2020-06-23 00:58:56 +08:00
|
|
|
{% endif %}
|
2021-08-03 22:06:53 +08:00
|
|
|
--pids-limit={{ 0 if container_binary == 'podman' else -1 }} \
|
2017-09-06 16:53:30 +08:00
|
|
|
--memory={{ ceph_mon_docker_memory_limit }} \
|
2017-10-16 21:16:48 +08:00
|
|
|
--cpus={{ ceph_mon_docker_cpu_limit }} \
|
2022-03-07 17:31:14 +08:00
|
|
|
--security-opt label=disable \
|
|
|
|
-v /var/lib/ceph:/var/lib/ceph:rshared \
|
|
|
|
-v /etc/ceph:/etc/ceph \
|
|
|
|
-v /var/run/ceph:/var/run/ceph \
|
|
|
|
-v /etc/localtime:/etc/localtime \
|
|
|
|
-v /var/log/ceph:/var/log/ceph \
|
|
|
|
{% if ansible_facts['os_family'] == 'RedHat' -%}
|
|
|
|
-v /etc/pki/ca-trust/extracted:/etc/pki/ca-trust/extracted \
|
2019-08-26 22:47:05 +08:00
|
|
|
{% endif -%}
|
2020-09-26 00:15:02 +08:00
|
|
|
{% if mon_docker_privileged | bool -%}
|
2017-09-06 16:53:30 +08:00
|
|
|
--privileged \
|
2017-11-02 21:53:46 +08:00
|
|
|
{% endif -%}
|
2020-09-26 00:15:02 +08:00
|
|
|
{% if mon_docker_net_host | bool -%}
|
2017-09-06 16:53:30 +08:00
|
|
|
--net=host \
|
2017-11-02 21:53:46 +08:00
|
|
|
{% endif -%}
|
2017-09-06 16:53:30 +08:00
|
|
|
-e IP_VERSION={{ ip_version[-1:] }} \
|
2018-10-15 21:25:24 +08:00
|
|
|
-e MON_IP={{ _current_monitor_address }} \
|
2017-08-31 18:04:40 +08:00
|
|
|
-e CLUSTER={{ cluster }} \
|
|
|
|
-e FSID={{ fsid }} \
|
2019-01-09 20:23:07 +08:00
|
|
|
-e MON_PORT={{ ceph_mon_container_listen_port }} \
|
2018-01-30 21:39:58 +08:00
|
|
|
-e CEPH_PUBLIC_NETWORK={{ public_network | regex_replace(' ', '') }} \
|
2017-08-31 18:04:40 +08:00
|
|
|
-e CEPH_DAEMON=MON \
|
2019-03-05 22:28:14 +08:00
|
|
|
-e CONTAINER_IMAGE={{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} \
|
2021-06-30 01:24:29 +08:00
|
|
|
-e TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES={{ ceph_tcmalloc_max_total_thread_cache }} \
|
2017-09-06 16:53:30 +08:00
|
|
|
{{ ceph_mon_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-mon-%i
|
2020-06-23 00:58:56 +08:00
|
|
|
{% endif %}
|
mon: ensure socker is purged when mon is stopped
On containerized deployment, if a mon is stopped, the socket is not
purged and can cause failure when a cluster is redeployed after the
purge playbook has been run.
Typical error:
```
fatal: [osd0]: FAILED! => {}
MSG:
'dict object' has no attribute 'osd_pool_default_pg_num'
```
the fact is not set because of this previous failure earlier:
```
ok: [mon0] => {
"changed": false,
"cmd": "docker exec ceph-mon-mon0 ceph --cluster test daemon mon.mon0 config get osd_pool_default_pg_num",
"delta": "0:00:00.217382",
"end": "2018-07-09 22:25:53.155969",
"failed_when_result": false,
"rc": 22,
"start": "2018-07-09 22:25:52.938587"
}
STDERR:
admin_socket: exception getting command descriptions: [Errno 111] Connection refused
MSG:
non-zero return code
```
This failure happens when the ceph-mon service is stopped, indeed, since
the socket isn't purged, it's a leftover which is confusing the process.
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
2018-07-10 17:56:17 +08:00
|
|
|
ExecStopPost=-/bin/rm -f /var/run/ceph/{{ cluster }}-mon.{{ monitor_name }}.asok
|
2020-02-11 23:09:51 +08:00
|
|
|
KillMode=none
|
2016-01-28 03:50:05 +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-01-28 03:50:05 +08:00
|
|
|
|
|
|
|
[Install]
|
2021-08-10 21:21:19 +08:00
|
|
|
WantedBy=ceph.target
|