container: use tmpfiles.d to creates /run/ceph

instead of using `RuntimeDirectory` parameter in systemd unit files,
let's use a systemd `tmpfiles.d` to ensure `/run/ceph`.

Explanation:

`podman` doesn't create the `/var/run/ceph` if it doesn't exist the time
where the container is run while `docker` used to create it.
In case of `switch_to_containers` scenario, `/run/ceph` gets created by
a tmpfiles.d systemd file; when switching to containers, the systemd
unit file complains because `/run/ceph` already exists

The better fix would be to ensure `/usr/lib/tmpfiles.d/ceph-common.conf`
is removed and only rely on `RuntimeDirectory` from systemd unit file parameter
but we come from a non-containerized environment which is already running,
it means `/run/ceph` is already created and when starting the unit to
start the container, systemd will still complain and we can't simply
remove the directory if daemons are collocated.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/3594/head
Guillaume Abrioux 2019-02-10 08:21:43 +01:00 committed by Sébastien Han
parent 7e0a70f7a8
commit 8c8ec63633
8 changed files with 10 additions and 8 deletions

View File

@ -88,4 +88,13 @@
with_pkg
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- ansible_distribution_major_version == '8'
- name: ensure tmpfiles.d is present
lineinfile:
path: /usr/lib/tmpfiles.d/ceph-common.conf
line: "d /run/ceph 0770 ceph ceph -"
owner: root
group: root
mode: 0644
state: present

View File

@ -4,7 +4,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \

View File

@ -4,7 +4,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \

View File

@ -4,7 +4,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i
ExecStartPre=/bin/sh -c '"$(command -v mkdir)" -p /etc/ceph /var/lib/ceph/mon'
ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-mon-%i \

View File

@ -5,7 +5,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-nfs-%i
ExecStartPre=/usr/bin/mkdir -p /etc/ceph /etc/ganesha /var/lib/nfs/ganesha
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \

View File

@ -5,7 +5,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
{% if osd_scenario == 'lvm' -%}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i

View File

@ -4,7 +4,6 @@ After=docker.service
[Service]
EnvironmentFile=-/etc/environment
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rbd-mirror-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \

View File

@ -4,7 +4,6 @@ After=docker.service
[Service]
EnvironmentFile=/var/lib/ceph/radosgw/ceph-%i/EnvironmentFile
RuntimeDirectory=ceph
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \