164 lines
4.8 KiB
YAML
164 lines
4.8 KiB
YAML
---
|
|
_service_container_socket_mount:
|
|
type: bind
|
|
source: /run/{{ service_name }}.sock
|
|
destination: /run/{{ service_name }}.sock
|
|
|
|
_service_volume_mounts: "{{ service_container_mounts | selectattr('type', '==', 'volume') }}"
|
|
_service_template_mounts: "{{ service_container_mounts | selectattr('type', '==', 'template') }}"
|
|
_service_copy_mounts: "{{ service_container_mounts | selectattr('type', '==', 'copy') }}"
|
|
_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_socket_mount ] if _service_native_socket else [])
|
|
}}
|
|
|
|
_service_template_mounts_hostfiles: >-
|
|
{{
|
|
_service_template_mounts
|
|
| map(attribute='destination')
|
|
| map('dirname')
|
|
| map('replace', '/', '_')
|
|
| map('regex_replace', '^', _service_host_directory ~ '/mounts/')
|
|
| zip(
|
|
_service_template_mounts
|
|
| map(attribute='destination')
|
|
| map('basename')
|
|
)
|
|
| map('path_join')
|
|
| map('community.general.dict_kv', 'hostfile')
|
|
}}
|
|
_service_template_mounts_full: >-
|
|
{{
|
|
([{'readonly': true, 'template_directory': false}] * _service_template_mounts | length)
|
|
| zip(
|
|
_service_template_mounts,
|
|
_service_template_mounts_hostfiles
|
|
)
|
|
| map('combine')
|
|
}}
|
|
_service_template_mounts_plain: "{{ _service_template_mounts_full | rejectattr('template_directory') }}"
|
|
_service_container_template_mounts_plain: >-
|
|
{{
|
|
_service_template_mounts_plain
|
|
| community.general.remove_keys(['mode', 'template_validate_command', 'template_directory', 'hostfile'])
|
|
| zip(
|
|
_service_template_mounts_plain
|
|
| map(attribute='hostfile')
|
|
| map('community.general.dict_kv', 'source'),
|
|
([{'type': 'bind'}] * _service_template_mounts_plain | length)
|
|
) |
|
|
map('combine')
|
|
}}
|
|
_service_template_mounts_directory: "{{ _service_template_mounts_full | selectattr('template_directory') }}"
|
|
_service_container_template_mounts_directory: >-
|
|
{{
|
|
_service_template_mounts_directory
|
|
| community.general.remove_keys(['mode', 'template_validate_command', 'template_directory', 'hostfile'])
|
|
| zip(
|
|
_service_template_mounts_directory
|
|
| map(attribute='hostfile')
|
|
| map('dirname')
|
|
| map('community.general.dict_kv', 'source'),
|
|
([{'type': 'bind'}] * _service_template_mounts_directory | length)
|
|
)
|
|
| map('combine')
|
|
| unique
|
|
}}
|
|
|
|
_service_container_copy_mounts: >-
|
|
{{
|
|
([{'readonly': true}] * _service_copy_mounts | length) |
|
|
zip(
|
|
_service_copy_mounts |
|
|
community.general.remove_keys(['mode']),
|
|
_service_copy_mounts |
|
|
map(attribute='source') |
|
|
map('regex_replace', '\/$', '') |
|
|
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
|
map('community.general.dict_kv', 'source'),
|
|
([{'type': 'bind'}] * _service_copy_mounts | length)
|
|
) |
|
|
map('combine')
|
|
}}
|
|
|
|
_service_container_mounts: >-
|
|
{{
|
|
_service_container_volume_mounts
|
|
+ _service_container_bind_mounts
|
|
+ _service_container_template_mounts_plain
|
|
+ _service_container_template_mounts_directory
|
|
+ _service_container_copy_mounts
|
|
}}
|
|
|
|
|
|
_service_all_template_mounts: >-
|
|
{{
|
|
(
|
|
_service_template_mounts
|
|
+ (
|
|
_service_additional_containers
|
|
| map(attribute='mounts', default=[])
|
|
| flatten
|
|
)
|
|
)
|
|
| selectattr('type', '==', 'template')
|
|
| unique
|
|
}}
|
|
_service_all_template_mount_host_files: >-
|
|
{{
|
|
_service_all_template_mounts
|
|
| map(attribute='destination')
|
|
| map('dirname')
|
|
| map('replace', '/', '_')
|
|
| map('regex_replace', '^', _service_host_directory ~ '/mounts/')
|
|
| zip(
|
|
_service_all_template_mounts
|
|
| map(attribute='destination')
|
|
| map('basename')
|
|
)
|
|
| map('path_join')
|
|
}}
|
|
_service_all_template_mounts_full: >-
|
|
{{
|
|
([{'readonly': true, 'template_directory': false}] * _service_all_template_mounts | length)
|
|
| zip(
|
|
_service_all_template_mounts,
|
|
_service_all_template_mount_host_files | map('community.general.dict_kv', 'hostfile')
|
|
)
|
|
| map('combine')
|
|
}}
|
|
|
|
_service_all_copy_mounts: >-
|
|
{{
|
|
(
|
|
_service_copy_mounts +
|
|
(
|
|
_service_additional_containers |
|
|
map(attribute='mounts', default=[]) |
|
|
flatten
|
|
)
|
|
) |
|
|
selectattr('type', '==', 'copy') |
|
|
unique
|
|
}}
|
|
_service_all_copy_mount_host_files: >-
|
|
{{
|
|
_service_all_copy_mounts
|
|
| map(attribute='source')
|
|
| map('regex_replace', '^', _service_host_directory ~ '/mounts/')
|
|
}}
|