[Unit]
Description={{ lookup('dict', container_data).key }} container
After=tripleo-container-shutdown.service
{% if lookup('dict', container_data).value.depends_on | default([]) | length > 0 %}
After={{ lookup('dict', container_data).value.depends_on | default([]) | join(' ') }}
Wants={{ lookup('dict', container_data).value.depends_on | default([]) | join(' ') }}
{% endif %}
[Service]
Restart=always
{% if lookup('dict', container_data).value.depends_on is defined and (lookup('dict', container_data).value.depends_on | length > 0) and podman_drop_in | default('false') %}
ExecStart=/usr/libexec/tripleo-start-podman-container {{ lookup('dict', container_data).key }}
{% else %}
ExecStart=/usr/bin/podman start {{ lookup('dict', container_data).key }}
{% endif %}
ExecReload=/usr/bin/podman kill --signal HUP {{ lookup('dict', container_data).key }}
ExecStop=/usr/bin/podman stop -t {{ lookup('dict', container_data).value.stop_grace_period | default(42) | int }} {{ lookup('dict', container_data).key }}
ExecStopPost=/usr/bin/podman stop -t {{ lookup('dict', container_data).value.stop_grace_period | default(42) | int }} {{ lookup('dict', container_data).key }}
SuccessExitStatus=137 142 143
TimeoutStopSec={{ 2*(lookup('dict', container_data).value.stop_grace_period | default(42) | int) }}
KillMode={{ lookup('dict', container_data).value.kill_mode | default('control-group') }}
Type=forking
PIDFile=/var/run/{{ lookup('dict', container_data).key }}.pid
{% if lookup('dict', container_data).value.systemd_exec_flags is defined %}
{%   for s_flag, s_value in lookup('dict', container_data).value.systemd_exec_flags.items() %}
{{ s_flag }}={{ s_value }}
{%   endfor %}
{% endif %}
[Install]
WantedBy=multi-user.target
