Files
Kamino/roles/docker/tasks/validate.yml
T
Dragonish 887302b208
Build / build (pull_request) Successful in 51s
Molecule / molecule (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 1m20s
feat(docker): manage /etc/docker/daemon.json (live-restore, log driver, extra options)
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
2026-11-25 19:42:06 +00:00

60 lines
2.9 KiB
YAML

---
# Fact-computing and assertion only, before any task changes the host. A removal does not write the apt source, so it does not need the architecture.
- name: Work out the apt architecture
ansible.builtin.set_fact:
__docker_apt_arch: >-
{{ docker_apt_arch | default('', true) or __docker_arch_by_fact[ansible_facts['architecture'] | default('')] | default('', true) }}
tags: always
# The value is written into the one-line apt source (deb [arch=... signed-by=...]): a space or a bracket would corrupt it.
- name: Check the apt architecture
ansible.builtin.assert:
that:
- __docker_apt_arch is match('^[a-z0-9]+\Z')
fail_msg: >-
{% if docker_apt_arch | default('', true) | length > 0 %}
docker_apt_arch '{{ docker_apt_arch }}' is not a valid apt architecture name: use the name Docker publishes (for example amd64 or arm64),
lowercase letters and digits only.
{% else %}
The host architecture '{{ ansible_facts['architecture'] | default('unknown') }}' has no known Docker apt architecture (x86_64 and aarch64 do).
Set docker_apt_arch to the name Docker publishes for it, for example armhf.
{% endif %}
quiet: true
tags: always
- name: Check the unit timings
ansible.builtin.assert:
that:
- docker_start_missed_settle_seconds | int(-1) >= 0
- docker_stop_at_shutdown_timeout | int(0) >= 1
fail_msg: >-
docker_start_missed_settle_seconds must be a whole number of at least 0 and docker_stop_at_shutdown_timeout a whole number of at least 1.
quiet: true
tags: always
# The values go into daemon.json, which dockerd refuses to start with when it holds a bad one, so a shape check stops the run first.
- name: Check the daemon log settings
ansible.builtin.assert:
that:
- docker_log_driver is match('^[a-z0-9-]*\Z')
- docker_log_max_size is match('^(-1|[0-9]+[kKmMgG]?)?\Z')
- docker_log_max_file is match('^[0-9]*\Z')
- docker_log_max_file | length == 0 or docker_log_max_file | int >= 1
fail_msg: >-
docker_log_driver must be empty or lowercase letters, digits and -; docker_log_max_size empty, -1 or a whole number with an optional
k, m or g (for example 10m); docker_log_max_file empty or a whole number of at least 1 (quote it).
quiet: true
tags: always
- name: Refuse a daemon option that a dedicated input also sets
ansible.builtin.assert:
that:
- not (docker_live_restore | bool and 'live-restore' in docker_daemon_options)
- not (docker_log_driver | length > 0 and 'log-driver' in docker_daemon_options)
- not ((docker_log_max_size | length > 0 or docker_log_max_file | length > 0) and 'log-opts' in docker_daemon_options)
fail_msg: >-
docker_daemon_options sets a key that a dedicated input also sets: live-restore (docker_live_restore), log-driver (docker_log_driver)
or log-opts (docker_log_max_size and docker_log_max_file). Set it in one place.
quiet: true
tags: always