Skip to content

Commit

Permalink
fix(environ): ensure environ is loaded by systemd using a drop-in
Browse files Browse the repository at this point in the history
  • Loading branch information
benfiedler committed Sep 5, 2024
1 parent 24ecc4b commit 1a82584
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions docker/software/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
33 changes: 33 additions & 0 deletions docker/software/config/dropin.sls
Original file line number Diff line number Diff line change
@@ -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 %}
1 change: 1 addition & 0 deletions docker/software/config/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

include:
- .environ
- .dropin
- .daemon
12 changes: 12 additions & 0 deletions docker/software/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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' %}
Expand Down Expand Up @@ -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:
Expand All @@ -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' %}
Expand Down

0 comments on commit 1a82584

Please sign in to comment.