47 lines
1.1 KiB
Django/Jinja
47 lines
1.1 KiB
Django/Jinja
# {{ ansible_managed }}
|
|
|
|
[Unit]
|
|
Description=Container {{ container_name }}
|
|
{% for requirement in container_requires %}
|
|
Requires={{ requirement }}
|
|
After={{ requirement }}
|
|
{% endfor %}
|
|
{% for want in container_wants %}
|
|
Requires={{ want }}
|
|
Before={{ want }}
|
|
{% endfor %}
|
|
|
|
[Container]
|
|
Image={{ container_image }}
|
|
ContainerName={{ container_name }}
|
|
{% if container_command | length > 0 %}
|
|
Exec="{{ container_command | join('" "') }}"
|
|
{% endif %}
|
|
{% if container_user | length > 0 %}
|
|
User={{ container_user }}
|
|
{% endif %}
|
|
{% for mount in container_mounts %}
|
|
Mount={% for key, value in mount.items() %}{{ key }}={{ value }}{% if not loop.last %},{% endif %}{% endfor %}
|
|
|
|
{% endfor %}
|
|
{% for network in container_networks %}
|
|
Network={{ network }}.network
|
|
{% endfor %}
|
|
{% for port in container_publish_ports %}
|
|
PublishPort={{ port }}
|
|
{% endfor %}
|
|
{% for key, value in container_env.items() %}
|
|
Environment={{ key }}={{ value }}
|
|
{% endfor %}
|
|
{% if container_auto_update %}
|
|
AutoUpdate=registry
|
|
{% endif %}
|
|
|
|
{% if container_auto_start %}
|
|
[Service]
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
{% endif %}
|