""" % (fsid, ' '.join(targets), '|'.join(targets)))
-_TMPL_DAEMON_UNIT = """# generated by cephadm
-[Unit]
-Description=Ceph %i for {{fsid}}
-
-# According to:
-# http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
-# these can be removed once ceph-mon will dynamically change network
-# configuration.
-After=network-online.target local-fs.target time-sync.target{% if has_docker_engine %} docker.service{% endif %}
-Wants=network-online.target local-fs.target time-sync.target
-{%- if has_docker_engine %}
-Requires=docker.service
-{%- endif %}
-
-PartOf=ceph-{{fsid}}.target
-Before=ceph-{{fsid}}.target
-
-[Service]
-LimitNOFILE=1048576
-LimitNPROC=1048576
-EnvironmentFile=-/etc/environment
-ExecStart=/bin/bash {{ctx.data_dir}}/{{fsid}}/%i/unit.run
-ExecStop=-/bin/bash -c 'bash {{ctx.data_dir}}/{{fsid}}/%i/unit.stop'
-ExecStopPost=-/bin/bash {{ctx.data_dir}}/{{fsid}}/%i/unit.poststop
-KillMode=none
-Restart=on-failure
-RestartSec=10s
-TimeoutStartSec=200
-TimeoutStopSec=120
-StartLimitInterval=30min
-StartLimitBurst=5
-{%- if has_podman_engine %}
-ExecStartPre=-/bin/rm -f %t/%n-pid %t/%n-cid
-ExecStopPost=-/bin/rm -f %t/%n-pid %t/%n-cid
-Type=forking
-PIDFile=%t/%n-pid
-{%- if has_podman_split_version %}
-Delegate=yes
-{%- endif %}
-{%- endif %}
-
-[Install]
-WantedBy=ceph-{{fsid}}.target
-"""
-
-
def get_unit_file(ctx: CephadmContext, fsid: str) -> str:
has_docker_engine = isinstance(ctx.container_engine, Docker)
has_podman_engine = isinstance(ctx.container_engine, Podman)
has_podman_split_version = (
has_podman_engine and ctx.container_engine.supports_split_cgroups
)
- return templating.template_str(
+ return templating.render(
ctx,
- _TMPL_DAEMON_UNIT,
+ templating.Templates.ceph_service,
fsid=fsid,
has_docker_engine=has_docker_engine,
has_podman_engine=has_podman_engine,
return ('set -e\n' + f'{py3} {binary_path} agent --fsid {self.fsid} --daemon-id {self.daemon_id} &\n')
def unit_file(self) -> str:
- ts = """#generated by cephadm
-[Unit]
-Description=cephadm agent for cluster {{agent.fsid}}
-
-PartOf=ceph-{{agent.fsid}}.target
-Before=ceph-{{agent.fsid}}.target
-
-[Service]
-Type=forking
-ExecStart=/bin/bash {{agent.daemon_dir}}/unit.run
-Restart=on-failure
-RestartSec=10s
-
-[Install]
-WantedBy=ceph-{{agent.fsid}}.target
-"""
- return templating.template_str(self.ctx, ts, agent=self)
+ return templating.render(
+ self.ctx, templating.Templates.agent_service, agent=self
+ )
def shutdown(self) -> None:
self.stop = True