67 lines
2.0 KiB
YAML
67 lines
2.0 KiB
YAML
---
|
|
_container_image: "{{ container_image | replace('/', '_') ~ '.image' }}"
|
|
|
|
_container_volumes: "{{ container_mounts | selectattr('type', '==', 'volume') }}"
|
|
|
|
_container_mount_sources: "{{ container_mounts | map(attribute='source') }}"
|
|
_container_mount_destinations: "{{ container_mounts | map(attribute='destination') }}"
|
|
|
|
_container_volume_mount_sources: >-
|
|
{{
|
|
_container_volumes
|
|
| map(attribute='source')
|
|
| map('regex_replace', '$', '.volume')
|
|
| map('community.general.dict_kv', 'source')
|
|
}}
|
|
|
|
_container_mounts: >-
|
|
{{
|
|
container_mounts | selectattr('type', '!=', 'volume') +
|
|
container_mounts | selectattr('type', '==', 'volume')
|
|
| community.general.keep_keys(['type', 'source', 'destination', 'readonly'])
|
|
| zip(_container_volume_mount_sources) | map('combine')
|
|
}}
|
|
|
|
_container_secrets: >-
|
|
{{
|
|
container_secrets
|
|
| map(attribute='name')
|
|
| zip(
|
|
container_secrets
|
|
| map(attribute='type', default='mount')
|
|
| map('regex_replace', '^', 'type='),
|
|
container_secrets
|
|
| map(attribute='name')
|
|
| map('community.general.dict_kv', 'target')
|
|
| zip(container_secrets)
|
|
| map('combine')
|
|
| map(attribute='target')
|
|
| map('regex_replace', '^', 'target=')
|
|
)
|
|
| map('join', ',')
|
|
}}
|
|
|
|
_container_quadlet_unit_options: |
|
|
[Unit]
|
|
Description=Container {{ container_name }}
|
|
StartLimitIntervalSec=30
|
|
StartLimitBurst=3
|
|
{% for requirement in container_requires %}
|
|
Requires={{ requirement }}
|
|
After={{ requirement }}
|
|
{% endfor %}
|
|
{% for want in container_wants %}
|
|
Wants={{ want }}
|
|
{% endfor %}
|
|
_container_quadlet_auto_start_options: |
|
|
[Service]
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
_container_quadlet_options_incl_empty:
|
|
- "{{ 'AutoUpdate=registry' if container_auto_update else '' }}"
|
|
- "{{ _container_quadlet_unit_options }}"
|
|
- "{{ _container_quadlet_auto_start_options if container_auto_start else '' }}"
|
|
_container_quadlet_options: "{{ _container_quadlet_options_incl_empty | select('!=', '') }}"
|