From 8c8ec636337e85efea5095ecd5b1fab17fdd51e6 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Sun, 10 Feb 2019 08:21:43 +0100 Subject: [PATCH] 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 --- .../tasks/pre_requisites/prerequisites.yml | 11 ++++++++++- roles/ceph-mds/templates/ceph-mds.service.j2 | 1 - roles/ceph-mgr/templates/ceph-mgr.service.j2 | 1 - roles/ceph-mon/templates/ceph-mon.service.j2 | 1 - roles/ceph-nfs/templates/ceph-nfs.service.j2 | 1 - roles/ceph-osd/templates/ceph-osd.service.j2 | 1 - .../templates/ceph-rbd-mirror.service.j2 | 1 - roles/ceph-rgw/templates/ceph-radosgw.service.j2 | 1 - 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml b/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml index bfa04ef88..d6601d12d 100644 --- a/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml +++ b/roles/ceph-container-common/tasks/pre_requisites/prerequisites.yml @@ -88,4 +88,13 @@ with_pkg when: - ansible_os_family == 'RedHat' - - ansible_distribution_major_version == '8' \ No newline at end of file + - 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 diff --git a/roles/ceph-mds/templates/ceph-mds.service.j2 b/roles/ceph-mds/templates/ceph-mds.service.j2 index 956917500..38c4b1691 100644 --- a/roles/ceph-mds/templates/ceph-mds.service.j2 +++ b/roles/ceph-mds/templates/ceph-mds.service.j2 @@ -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 \ diff --git a/roles/ceph-mgr/templates/ceph-mgr.service.j2 b/roles/ceph-mgr/templates/ceph-mgr.service.j2 index e52a68ac3..889862051 100644 --- a/roles/ceph-mgr/templates/ceph-mgr.service.j2 +++ b/roles/ceph-mgr/templates/ceph-mgr.service.j2 @@ -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 \ diff --git a/roles/ceph-mon/templates/ceph-mon.service.j2 b/roles/ceph-mon/templates/ceph-mon.service.j2 index 8485e23b0..79718a15f 100644 --- a/roles/ceph-mon/templates/ceph-mon.service.j2 +++ b/roles/ceph-mon/templates/ceph-mon.service.j2 @@ -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 \ diff --git a/roles/ceph-nfs/templates/ceph-nfs.service.j2 b/roles/ceph-nfs/templates/ceph-nfs.service.j2 index 8e57e2dcc..82cc61759 100644 --- a/roles/ceph-nfs/templates/ceph-nfs.service.j2 +++ b/roles/ceph-nfs/templates/ceph-nfs.service.j2 @@ -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 \ diff --git a/roles/ceph-osd/templates/ceph-osd.service.j2 b/roles/ceph-osd/templates/ceph-osd.service.j2 index 8e775661c..fc46baf11 100644 --- a/roles/ceph-osd/templates/ceph-osd.service.j2 +++ b/roles/ceph-osd/templates/ceph-osd.service.j2 @@ -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 diff --git a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 index 0073e17b6..a25633c0a 100644 --- a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 +++ b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 @@ -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 \ diff --git a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 index 0a69f544a..1e05a8cec 100644 --- a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 +++ b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 @@ -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 \