forked from openstack/kolla-ansible
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PoC: run containers in systemd services
Change-Id: I3d55ad828c1e1e123f023f27ce21a9cbf71042ee
- Loading branch information
1 parent
059c735
commit e44d4b0
Showing
4 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[Unit] | ||
Description=Glance API | ||
{% if container_binary == 'docker' %} | ||
After=docker.service | ||
Requires=docker.service | ||
{% else %} | ||
After=network.target | ||
{% endif %} | ||
|
||
[Service] | ||
EnvironmentFile=-/etc/environment | ||
{% if container_binary == 'podman' %} | ||
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid | ||
ExecStartPre=-/usr/bin/{{ container_binary }} rm --storage {{ item.value.container_name }} | ||
{% else %} | ||
ExecStartPre=-/usr/bin/{{ container_binary }} stop {{ item.value.container_name }} | ||
{% endif %} | ||
ExecStartPre=-/usr/bin/{{ container_binary }} rm {{ item.value.container_name }} | ||
{# TODO: dimensions, healthcheck #} | ||
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ | ||
{% if container_binary == 'podman' %} | ||
-d --log-driver journald --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ | ||
This comment has been minimized.
Sorry, something went wrong. |
||
{% endif %} | ||
{% for volume in item.value.volumes | select | list %} | ||
-v {{ volume }} \ | ||
{% endfor %} | ||
--name={{ item.value.container_name }} \ | ||
{% if item.value.privileged | bool %} | ||
--privileged \ | ||
{% endif %} | ||
{% for key, value in item.value.environment.items() %} | ||
--env {{ key }}={{ value }} \ | ||
{% endfor %} | ||
{{ item.value.image }} | ||
{% if container_binary == 'podman' %} | ||
ExecStop=-/usr/bin/sh -c "/usr/bin/{{ container_binary }} rm -f `cat /%t/%n-cid`" | ||
{% else %} | ||
ExecStopPost=-/usr/bin/{{ container_binary }} stop {{ item.value.container_name }} | ||
{% endif %} | ||
KillMode=none | ||
Restart=always | ||
RestartSec=10s | ||
TimeoutStartSec=120 | ||
TimeoutStopSec=15 | ||
{% if container_binary == 'podman' %} | ||
Type=forking | ||
PIDFile=/%t/%n-pid | ||
{% endif %} | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
FIXME: multi-line configs not supported by merge_configs plugin.