haxorof/ansible-role-docker-ce

Docker daemon environment variables not set when SysVinit is used

haxorof opened this issue · 1 comments

Version Information

Ansible: core 2.12.4
Role: 3.7.1

Steps to Reproduce

Test on distribution that uses sysvinit instead of systemd like in the case when running Ubuntu 20.04 on WSL2

---
- hosts: test-host
  vars:
    docker_daemon_envs:
      TESTVAR: "1"
  roles:
    - haxorof.docker_ce

Expected Behavior

TESTVAR visible when looking at environment variables for the dockerd process

Actual Behavior

TESTVAR not visible since it seem for SysVinit it also is necessary to export the variables.

Added to bottom of docker-envs.j2

{% if not _docker_systemd_used and (docker_envs.items()|list)|length > 0  %}
export{% for key, value in docker_envs.items()|list %} {{ key }}{% endfor %}
{% endif %}