From 537ef1c2fcbf6361f6a044e454915587d567dccf Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 5 Jun 2023 22:43:15 +0200 Subject: [PATCH] use multiline string for dockerengine_service_override_unit --- defaults/main.yml | 11 ++++++++++- .../systemd/system/docker.service.d/override.conf.j2 | 7 +++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6fccb37..d6e482c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,7 +18,16 @@ dockerengine_ansible_deps: - docker dockerengine_service: docker -dockerengine_service_override_unit: [] + +# @var dockerengine_service_override_unit:description: > +# Multiline string of options to add to the `systemd` service override unit section. +# @end +# @var dockerengine_service_override_unit: $ "_unset_" +# @var dockerengine_service_override_unit:example: > +# dockerengine_service_override_unit: | +# After=time-sync.target +# Requires=time-sync.target +# @end dockerengine_docker_group_enabled: False diff --git a/templates/etc/systemd/system/docker.service.d/override.conf.j2 b/templates/etc/systemd/system/docker.service.d/override.conf.j2 index 85ea03c..7d51f7c 100644 --- a/templates/etc/systemd/system/docker.service.d/override.conf.j2 +++ b/templates/etc/systemd/system/docker.service.d/override.conf.j2 @@ -1,10 +1,9 @@ #jinja2: lstrip_blocks: True {{ ansible_managed | comment }} -{% if dockerengine_service_override_unit | default([]) | length > 0 %} +{% if dockerengine_service_override_unit is defined %} [Unit] -{% for item in dockerengine_service_override_unit %} -{{ item }} -{% endfor %} +{{ dockerengine_service_override_unit }} +{% endif %} [Service] EnvironmentFile=-/etc/sysconfig/docker ExecStart=