From 2c275b9f1c2172a40e9f836df2beb964adba1486 Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Sat, 9 Dec 2023 17:47:35 +0100 Subject: [PATCH] feat(template): add support for simple string flags --- molecule/default_vagrant/group_vars/all.yml | 1 + templates/unit.j2 | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/molecule/default_vagrant/group_vars/all.yml b/molecule/default_vagrant/group_vars/all.yml index f4a6cb9..6f2f7f4 100644 --- a/molecule/default_vagrant/group_vars/all.yml +++ b/molecule/default_vagrant/group_vars/all.yml @@ -5,6 +5,7 @@ docker_systemd_service_container_env: {} docker_systemd_service_container_pull_image: true docker_systemd_service_container_pull_force_source: false docker_systemd_service_flags: + - privileged - network: host - volume: - /root:/mnt/volume diff --git a/templates/unit.j2 b/templates/unit.j2 index 01aa6f7..9b2a8fb 100644 --- a/templates/unit.j2 +++ b/templates/unit.j2 @@ -6,15 +6,19 @@ {% endmacro -%} {%- macro create_docker_flag(item) %} +{%- if item is mapping %} {% set key = item.keys() | first %} {% set value = item[key] %} {%- if value is string %} --{{ key }} {{ value }} \ -{%- elif value is iterable and value is not string %} +{%- elif value is iterable %} {% for val in value %} --{{ key }} {{ val }} \{% if not loop.last +%} {% endif %}{% endfor %} {% endif -%} +{%- elif item is string %} +--{{ item }} \ +{%- endif -%} {% endmacro %} {% set service_systemd_options_keys = docker_systemd_service_systemd_options | selectattr("key") | map(attribute="key") | list %}