From cf59c5f807cbcf32d2fa5204d439260521b7f28d Mon Sep 17 00:00:00 2001 From: Corbin Bartsch Date: Sat, 28 Oct 2023 17:01:51 -0400 Subject: [PATCH] Add healthcheck and dependency conditions --- templates/docker-compose.yml.j2 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index 4741b95..3842474 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -1,4 +1,7 @@ {{ ansible_managed | comment }} +############################## +# If you're seeing this, you're using a symlinked version of this role. +############################## --- version: "{{ compose_schema_version | default('2') }}" services: @@ -74,7 +77,12 @@ services: {% if container.depends_on is defined %} depends_on: {% for dependent in container.depends_on %} +{% if dependent.condition is defined %} + {{ dependent }}: + condition: {{ dependent.condition }} +{% else %} - {{ dependent }} +{% endif %} {% endfor %} {% endif %} {% if container.hostname is defined %} @@ -154,8 +162,15 @@ services: - {{ envfile }} {% endfor %} {% endif %} -{% if container.user is defined %} - user: {{ container.user }} +{% if container.healthcheck is defined %} + healthcheck: + test: {{ container.healthcheck.test }} + interval: {{ container.healthcheck.interval }} + timeout: {{ container.healthcheck.timeout }} +{% if container.healthcheck.retries is defined %} + retries: {{ container.healthcheck.retries }} +{% endif %} + start_period: {{ container.healthcheck.start_period }} {% endif %} {% if container.restart is defined %} restart: {{ container.restart }}