97 lines
3.0 KiB
YAML
97 lines
3.0 KiB
YAML
---
|
|
_service_volume_mounts: "{{ service_container_mounts | selectattr('type', '==', 'volume') }}"
|
|
_service_template_mounts: "{{ service_container_mounts | selectattr('type', '==', 'template') }}"
|
|
_service_host_directory: "/srv/{{ service_name }}"
|
|
|
|
_service_container_volume_mounts: >-
|
|
{{
|
|
_service_volume_mounts |
|
|
zip(
|
|
_service_volume_mounts |
|
|
map(attribute='source') |
|
|
map('regex_replace', '^', service_name ~ '-') |
|
|
map('community.general.dict_kv', 'source')
|
|
) |
|
|
map('combine')
|
|
}}
|
|
_service_container_bind_mounts: "{{ service_container_mounts | selectattr('type', '==', 'bind') }}"
|
|
_service_container_template_mounts: >-
|
|
{{
|
|
([{'readonly': true}] * _service_template_mounts | length) |
|
|
zip(
|
|
_service_template_mounts,
|
|
_service_template_mounts |
|
|
map(attribute='source') |
|
|
map('regex_replace', '\.j2$', '') |
|
|
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
|
map('community.general.dict_kv', 'source'),
|
|
([{'type': 'bind'}] * _service_template_mounts | length)
|
|
) |
|
|
map('combine')
|
|
}}
|
|
|
|
_service_container_mounts: >-
|
|
{{
|
|
_service_container_volume_mounts +
|
|
_service_container_bind_mounts +
|
|
_service_container_template_mounts
|
|
}}
|
|
|
|
_service_setup_database: "{{ service_database_type != 'none' }}"
|
|
_service_database_name: "{{ service_name }}-{{ service_database_type }}"
|
|
|
|
_service_container_networks: "{{ [service_name] + service_container_additional_networks }}"
|
|
|
|
_service_container_secrets: >-
|
|
{{
|
|
service_container_secrets
|
|
| map(attribute='name')
|
|
| map('community.general.dict_kv', 'target')
|
|
| zip(
|
|
service_container_secrets,
|
|
service_container_secrets
|
|
| map(attribute='name')
|
|
| map('regex_replace', '^', service_name ~ '-')
|
|
| map('community.general.dict_kv', 'name')
|
|
)
|
|
| map('combine')
|
|
+ (
|
|
[{
|
|
'name': _service_database_name,
|
|
'type': service_database_secret_type,
|
|
'target': service_database_secret_target
|
|
}] if _service_setup_database else []
|
|
)
|
|
}}
|
|
|
|
_service_additional_containers: >-
|
|
{{
|
|
service_additional_containers
|
|
| zip(
|
|
service_additional_containers
|
|
| map(attribute='name')
|
|
| map('regex_replace', '^', service_name ~ '-')
|
|
| map('community.general.dict_kv', 'name')
|
|
)
|
|
| map('combine')
|
|
}}
|
|
|
|
_service_container_requires: >-
|
|
{{
|
|
service_requires
|
|
+ ([_service_database_name + '.service'] if _service_setup_database else [])
|
|
+ ([service_name + '-redis.service'] if service_redis else [])
|
|
}}
|
|
_service_container_wants: >-
|
|
{{
|
|
service_wants
|
|
+ ([service_name + '-socat.socket'] if service_domains | length > 0 else [])
|
|
+ _service_additional_containers
|
|
| map(attribute='name')
|
|
| map('regex_replace', '$', '.service')
|
|
}}
|
|
|
|
_service_replacement_host_header:
|
|
Host: "{{ service_name }}:{{ service_container_http_port }}"
|
|
_service_proxy_headers: "{{ _service_replacement_host_header if not service_proxy_pass_host_header else {} }}"
|