2023-12-03 21:56:21 +00:00
|
|
|
# {{ ansible_managed }}
|
2023-12-04 22:10:02 +00:00
|
|
|
{% set service_systemd_options_keys = docker_systemd_service_systemd_options | selectattr("key") | map(attribute="key") | list %}
|
2023-12-03 21:56:21 +00:00
|
|
|
[Unit]
|
2023-12-04 22:10:02 +00:00
|
|
|
{% for key, value in docker_systemd_service_systemd_unit_options | dictsort %}
|
2023-12-03 21:56:21 +00:00
|
|
|
{{ key }}={{ value }}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
[Service]
|
2023-12-04 22:10:02 +00:00
|
|
|
{% for item in docker_systemd_service_systemd_options %}
|
2023-12-03 21:56:21 +00:00
|
|
|
{{ item['key'] }}={{ item['value'] }}
|
|
|
|
{% endfor %}
|
|
|
|
{% if not 'EnvironmentFile' in service_systemd_options_keys %}
|
2023-12-04 22:10:02 +00:00
|
|
|
EnvironmentFile={{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_service_container_name }}
|
2023-12-03 21:56:21 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if not 'ExecStartPre' in service_systemd_options_keys %}
|
2023-12-04 22:10:02 +00:00
|
|
|
ExecStartPre=-{{ docker_systemd_service_docker_path }} rm -f {{ docker_systemd_service_container_name }}
|
2023-12-03 21:56:21 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if not 'ExecStart' in service_systemd_options_keys %}
|
2023-12-09 15:46:13 +00:00
|
|
|
ExecStart={{ docker_systemd_service_docker_path }} run --name {{ docker_systemd_service_container_name }} \
|
|
|
|
--rm \
|
|
|
|
--env-file {{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_service_container_name }} \
|
2023-12-09 17:36:25 +00:00
|
|
|
{{ docker_systemd_service_flags|create_docker_flags }}
|
|
|
|
{{ docker_systemd_service_image -}}{{ ' ' if docker_systemd_service_container_cmd else '' }}{% if docker_systemd_service_container_cmd is string %}{{ docker_systemd_service_container_cmd | trim }}{% else %}{{ docker_systemd_service_container_cmd | join(' ') | trim }}{% endif %}
|
2023-12-05 18:23:38 +00:00
|
|
|
{% endif +%}
|
2023-12-03 21:56:21 +00:00
|
|
|
{% if not 'ExecStop' in service_systemd_options_keys %}
|
2023-12-04 22:10:02 +00:00
|
|
|
ExecStop={{ docker_systemd_service_docker_path }} stop {{ docker_systemd_service_container_name }}
|
2023-12-03 21:56:21 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if container_start_post is defined %}
|
|
|
|
ExecStartPost=-{{ container_start_post }}
|
|
|
|
{% endif %}
|
|
|
|
{% if not 'SyslogIdentifier' in service_systemd_options_keys %}
|
2023-12-04 22:10:02 +00:00
|
|
|
SyslogIdentifier={{ docker_systemd_service_container_name }}
|
2023-12-03 21:56:21 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if not 'Restart' in service_systemd_options_keys %}
|
|
|
|
Restart=always
|
|
|
|
{% endif %}
|
|
|
|
{% if not 'RestartSec' in service_systemd_options_keys %}
|
|
|
|
RestartSec=10s
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
[Install]
|
2023-12-04 22:10:02 +00:00
|
|
|
WantedBy=docker.service
|