diff --git a/docker/defaults.yaml b/docker/defaults.yaml index f0f4a249..6000523c 100644 --- a/docker/defaults.yaml +++ b/docker/defaults.yaml @@ -35,6 +35,7 @@ docker: config: {} environ_file: /etc/default/docker environ: {} + dropin_file: /etc/systemd/system/docker.service.d/override.conf daemon_config_file: /etc/docker/daemon.json daemon_config: {} @@ -104,6 +105,7 @@ docker: base: /usr/local source: /usr/local/src/docker/libs service: /usr/lib/systemd/system + dropin: /etc/systemd/system/docker.service.d tmp: /tmp/saltstack-formulas-docker-tmp lib: /var/lib/docker linux: diff --git a/docker/software/config/clean.sls b/docker/software/config/clean.sls index 1b7aac2f..eab3edec 100644 --- a/docker/software/config/clean.sls +++ b/docker/software/config/clean.sls @@ -15,5 +15,7 @@ docker-software-config-clean: - names: - {{ d.pkg.docker.environ_file }} - {{ d.pkg.docker.daemon_config_file }} + - {{ d.pkg.docker.dropin_file }} + - {{ d.dir.dropin }} - require: - sls: {{ sls_archive_clean if d.pkg.docker.use_upstream == 'archive' else sls_package_clean }} diff --git a/docker/software/config/dropin.sls b/docker/software/config/dropin.sls new file mode 100644 index 00000000..f8878138 --- /dev/null +++ b/docker/software/config/dropin.sls @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# vim: ft=sls + +{%- set tplroot = tpldir.split('/')[0] %} +{%- from tplroot ~ "/map.jinja" import data as d with context %} + + {%- if 'environ' in d.pkg.docker and d.pkg.docker.environ and grains.os != 'Windows' %} + {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} + {%- set sls_environ = tplroot ~ '.software.config.environ' %} + +include: + - {{ sls_environ }} + +# Use a systemd dropin override to make use of the environ file +docker-software-config-dropin-file: + file.managed: + - name: {{ d.pkg.docker.dropin_file }} + - makedirs: True + - mode: '0755' + - user: {{ d.identity.rootuser }} + - group: {{ d.identity.rootgroup }} + - require: + - sls: {{ sls_environ }} + + ini.options_present: + - name: {{ d.pkg.docker.dropin_file }} + - sections: + Service: + EnvironmentFile: {{ d.pkg.docker.environ_file }} + - require: + - file: {{ d.pkg.docker.dropin_file }} + + {%- endif %} diff --git a/docker/software/config/init.sls b/docker/software/config/init.sls index 1f6decff..3727a4ef 100644 --- a/docker/software/config/init.sls +++ b/docker/software/config/init.sls @@ -3,4 +3,5 @@ include: - .environ + - .dropin - .daemon diff --git a/docker/software/service/running.sls b/docker/software/service/running.sls index 411c6cfe..7cd1f214 100644 --- a/docker/software/service/running.sls +++ b/docker/software/service/running.sls @@ -6,6 +6,7 @@ {%- if 'service' in d.pkg.docker and d.pkg.docker.service and grains.os != 'Windows' %} {%- set sls_config_daemon = tplroot ~ '.software.config.daemon' %} + {%- set sls_dropin = tplroot ~ '.software.config.dropin' %} {%- set sls_environ = tplroot ~ '.software.config.environ' %} {%- set sls_archive = tplroot ~ '.software.archive.install' %} {%- set sls_desktop = tplroot ~ '.software.desktop.install' %} @@ -38,6 +39,13 @@ docker-software-service-running-unmasked: {%- endif %} docker-software-service-running-docker: + {%- if 'environ' in d.pkg.docker and d.pkg.docker.environ %} + cmd.run: + - name: systemctl daemon-reload + - onchanges: + - sls: {{ sls_dropin }} + {%- endif %} + service.running: - name: {{ d.pkg.docker.service.name }} - require: @@ -48,6 +56,10 @@ docker-software-service-running-docker: - enable: True - watch: - file: docker-software-daemon-file-managed-daemon_file + {%- if 'environ' in d.pkg.docker and d.pkg.docker.environ %} + - sls: {{ sls_environ }} + - sls: {{ sls_dropin }} + {%- endif %} {%- if grains.kernel|lower == 'linux' %}