feat(docker): manage /etc/docker/daemon.json (live-restore, log driver, extra options)
Build / build (pull_request) Successful in 51s
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 1m20s

Adds docker_daemon_options, docker_live_restore, docker_log_driver,
docker_log_max_size, docker_log_max_file and docker_daemon_restart.

The file is written, before the packages are installed, only when one of
the first five is set, so a host that sets none is unchanged; the role
then owns the whole file. It restarts dockerd only when
docker_daemon_restart is true, because a restart with live-restore off
ends every container, and says so when the file applies later. A key set
by both docker_daemon_options and a dedicated input, and a bad log value,
stop the run before any change.

Closes #375

Assisted-by: Claude Code:claude-sonnet-5-5
This commit is contained in:
Dragonish committed 2026-11-25 19:42:06 +00:00
1 parent 428b88a822
commit 887302b208
10 files changed
+302 -1

No files matched your search

+44
View File
@@ -102,6 +102,50 @@ argument_specs:
default: 30
description:
- Seconds the unit waits for container processes to end after SIGTERM before it sends SIGKILL. At least 1.
docker_daemon_options:
type: dict
default: {}
description:
- >-
Keys merged as they are into C(/etc/docker/daemon.json), for any setting the dedicated inputs below do not cover. A key that a
dedicated input also sets (C(live-restore), C(log-driver) or C(log-opts)) stops the run. When this or any other daemon input is
set the role owns the whole file: a key it does not know is removed. Nothing is written when every daemon input is at its default.
docker_live_restore:
type: bool
default: false
description:
- >-
true writes C(live-restore) true to C(/etc/docker/daemon.json), so a C(docker.service) restart leaves running containers alone.
It takes effect at the next dockerd restart. Setting it back to false does not remove the key from a file already written.
docker_log_driver:
type: str
default: ""
description:
- >-
Default logging driver written as C(log-driver) (for example C(local) or C(json-file)); lowercase letters, digits and C(-).
Empty writes nothing. The role does not check that the driver accepts the log options below: dockerd refuses to start with one
it rejects.
docker_log_max_size:
type: str
default: ""
description:
- >-
Written as the C(max-size) log option, a whole number with an optional C(k), C(m) or C(g) (for example C(10m)), or C(-1).
Empty writes nothing.
docker_log_max_file:
type: str
default: ""
description:
- >-
Written as the C(max-file) log option, a whole number of at least 1. Quote it, because the input is a string. Empty writes
nothing.
docker_daemon_restart:
type: bool
default: false
description:
- >-
true restarts dockerd when C(/etc/docker/daemon.json) changed. false (the default) leaves the running daemon alone, because a
restart with C(live-restore) off ends every container; the file then applies at the next restart and the role says so.
docker_service:
type: str
default: docker