From b46674110299367007168496890207b404641cd7 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Sat, 9 Dec 2023 18:20:54 +0100 Subject: [PATCH] feat(template): test the type of data against list to enable passing integers or strings or lists --- molecule/default_vagrant/group_vars/all.yml | 3 +++ templates/unit.j2 | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/molecule/default_vagrant/group_vars/all.yml b/molecule/default_vagrant/group_vars/all.yml index 6f2f7f4..d797bed 100644 --- a/molecule/default_vagrant/group_vars/all.yml +++ b/molecule/default_vagrant/group_vars/all.yml @@ -10,6 +10,9 @@ docker_systemd_service_flags: - volume: - /root:/mnt/volume - /var:/test:ro + - health-cmd: curl localhost:80 + - health-retries: 10 + docker_systemd_service_container_cmd: [] #! TO REPLACE docker_systemd_service_container_labels: [] diff --git a/templates/unit.j2 b/templates/unit.j2 index 9b2a8fb..f671ce4 100644 --- a/templates/unit.j2 +++ b/templates/unit.j2 @@ -9,13 +9,13 @@ {%- if item is mapping %} {% set key = item.keys() | first %} {% set value = item[key] %} -{%- if value is string %} ---{{ key }} {{ value }} \ -{%- elif value is iterable %} +{%- if value.__class__.__name__ == 'list' %} {% for val in value %} ---{{ key }} {{ val }} \{% if not loop.last +%} +--{{ key }} "{{ val }}" \{% if not loop.last +%} {% endif %}{% endfor %} -{% endif -%} +{%- else %} +--{{ key }} "{{ value }}" \ +{%- endif %} {%- elif item is string %} --{{ item }} \ {%- endif -%}