feat(docker): manage /etc/docker/daemon.json (live-restore, log driver, extra options) #379

Merged
Defame1297 merged 2 commits from feat/375-docker-daemon-json into main 2026-11-25 20:07:24 +00:00
Collaborator

What and why

Closes #375.

The docker role did not manage /etc/docker/daemon.json, so a consumer kept a second role or a hand-edited file for the daemon's own settings (live-restore, the log driver and its limits).

New inputs, all with defaults that leave an existing host unchanged:

  • docker_daemon_options (dict): extra keys, merged as they are.
  • docker_live_restore (bool): writes "live-restore": true.
  • docker_log_driver, docker_log_max_size, docker_log_max_file (strings): written as log-driver and the max-size and max-file log options.
  • docker_daemon_restart (bool, default false): restarts dockerd when the file changed.

The file is written, before the packages are installed so that a first start of dockerd already reads it, only when one of the first five inputs is set. The role then owns the whole file: a key it does not know is removed. It never restarts dockerd unless docker_daemon_restart is true, because a restart with live-restore off ends every container; otherwise it says the file applies at the next restart. A key set both in docker_daemon_options and by a dedicated input, and a bad driver, size or file count, stop the run before any change.

Differences from the issue

  • The issue left open whether live-restore should be applied with a reload instead of a restart. I followed the proposal as written (restart only on request) and did not implement a reload; it can be a later change.
  • Removal: docker_remove leaves the file in place, as it does for a file the role cannot tell from the consumer's own. The README says so.

Verified

  • Every pre-commit hook passes, including yamllint, ansible-lint and the changelog fragment lint.
  • Through Ansible on localhost, with the real tasks/validate.yml and a copy of tasks/daemon.yml pointed at a temporary directory (owner and become removed in the copy): the 7 bad settings are each refused with a message that names an input; good values pass; nothing is written with the defaults; the file holds exactly the expected keys; a second run reports no change; the restart handler does not run with docker_daemon_restart: false and does with true; a second change replaces the whole file.

Not verified

  • The Molecule scenario has not run on this change. Its first CI run may fail, in particular the new check that reads the start time of the stand-in docker.service before and after a change.
  • A real dockerd starting with the written file. The stand-in service is sleep infinity, so CI shows the file and the restart logic, not that dockerd accepts the settings.
  • A log driver rejecting its options (the local driver refuses some combinations): the role checks the shape of the inputs, not that the driver accepts them. The README warns about it.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code:claude-sonnet-5-5

## What and why Closes #375. The `docker` role did not manage `/etc/docker/daemon.json`, so a consumer kept a second role or a hand-edited file for the daemon's own settings (`live-restore`, the log driver and its limits). New inputs, all with defaults that leave an existing host unchanged: - `docker_daemon_options` (dict): extra keys, merged as they are. - `docker_live_restore` (bool): writes `"live-restore": true`. - `docker_log_driver`, `docker_log_max_size`, `docker_log_max_file` (strings): written as `log-driver` and the `max-size` and `max-file` log options. - `docker_daemon_restart` (bool, default `false`): restarts dockerd when the file changed. The file is written, before the packages are installed so that a first start of dockerd already reads it, only when one of the first five inputs is set. The role then owns the whole file: a key it does not know is removed. It never restarts dockerd unless `docker_daemon_restart` is true, because a restart with `live-restore` off ends every container; otherwise it says the file applies at the next restart. A key set both in `docker_daemon_options` and by a dedicated input, and a bad driver, size or file count, stop the run before any change. ## Differences from the issue - The issue left open whether `live-restore` should be applied with a reload instead of a restart. I followed the proposal as written (restart only on request) and did not implement a reload; it can be a later change. - Removal: `docker_remove` leaves the file in place, as it does for a file the role cannot tell from the consumer's own. The README says so. ## Verified - Every pre-commit hook passes, including `yamllint`, `ansible-lint` and the changelog fragment lint. - Through Ansible on localhost, with the real `tasks/validate.yml` and a copy of `tasks/daemon.yml` pointed at a temporary directory (owner and `become` removed in the copy): the 7 bad settings are each refused with a message that names an input; good values pass; nothing is written with the defaults; the file holds exactly the expected keys; a second run reports no change; the restart handler does not run with `docker_daemon_restart: false` and does with `true`; a second change replaces the whole file. ## Not verified - The Molecule scenario has not run on this change. Its first CI run may fail, in particular the new check that reads the start time of the stand-in `docker.service` before and after a change. - A real dockerd starting with the written file. The stand-in service is `sleep infinity`, so CI shows the file and the restart logic, not that dockerd accepts the settings. - A log driver rejecting its options (the `local` driver refuses some combinations): the role checks the shape of the inputs, not that the driver accepts them. The README warns about it. --- - [ ] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code:claude-sonnet-5-5
Dragonish added 1 commit 2026-11-25 19:48:07 +00:00
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
887302b208
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
Defame1297 added 1 commit 2026-11-25 19:50:01 +00:00
Merge branch 'main' into feat/375-docker-daemon-json
Build / build (pull_request) Successful in 53s
Molecule / molecule (pull_request) Successful in 11m35s
Lint / lint (pull_request) Successful in 4m16s
3bc21bd630
Defame1297 approved these changes 2026-11-25 19:50:43 +00:00
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-25 19:51:11 +00:00
Defame1297 merged commit 3bfc485076 into main 2026-11-25 20:07:24 +00:00
Defame1297 deleted branch feat/375-docker-daemon-json 2026-11-25 20:07:30 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#379