--- - name: Set container named mounts ansible.builtin.set_fact: _service_container_mounts: > {{ _service_container_mounts + [mount | combine({'source': service_name + '-' + mount.source})] }} when: mount.type == 'volume' - name: Set container named mounts ansible.builtin.set_fact: _service_container_mounts: "{{ _service_container_mounts + [mount] }}" when: mount.type == 'bind' - name: Template mounts when: mount.type == 'template' block: - name: Set template host path ansible.builtin.set_fact: _service_template_host_path: "{{ _service_host_directory }}/mounts/{{ (mount.source | split('.'))[0:-1] | join('.') }}" # Strip .j2 extension - name: Template files for template mounts ansible.builtin.template: src: "{{ mount.source }}" dest: "{{ _service_template_host_path }}" mode: "0644" notify: "Restart container service {{ service_name }}" - name: Set container template mounts ansible.builtin.set_fact: _service_container_mounts: > {{ _service_container_mounts + [{'readonly': true} | combine(mount) | combine({'type': 'bind', 'source': _service_template_host_path})] }}