docker_start_missed installs a boot unit that starts the containers dockerd's restore pass skipped after a reboot of the whole host. docker_stop_at_shutdown installs a unit that ends container processes at shutdown while the network and NFS shares are still up, so a container holding an NFS mount no longer stalls the shutdown. Both default to false and do nothing without /usr/bin/docker. Refs #369 Assisted-by: Claude Code
123 lines
6.0 KiB
YAML
123 lines
6.0 KiB
YAML
---
|
|
argument_specs:
|
|
main:
|
|
short_description: Install, update or remove Docker Engine
|
|
description:
|
|
- >-
|
|
Installs Docker Engine from the upstream APT repository, or removes it when C(docker_remove) is true. Optionally updates the packages to
|
|
the current candidate versions, then adds C(docker_users) to C(docker_group).
|
|
- Needs gathered facts, because the APT source uses C(ansible_distribution_release).
|
|
options:
|
|
docker_remove:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Removes Docker instead of installing it. Stops the service, removes the packages, the APT source and the keyring,
|
|
and skips the install, update and group tasks.
|
|
docker_remove_data:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Only used with C(docker_remove). Purges the packages and deletes C(/var/lib/docker), which destroys images, containers and volumes.
|
|
docker_update:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Upgrades each package in C(docker_packages) to its current APT candidate version, pinned as package=version.
|
|
The C(Restart docker) handler is notified only when a package actually changes.
|
|
docker_packages:
|
|
type: list
|
|
elements: str
|
|
default: [docker-ce, docker-ce-cli, containerd.io]
|
|
description:
|
|
- Packages installed, updated or removed.
|
|
docker_keyring_path:
|
|
type: path
|
|
default: /etc/apt/keyrings/docker.asc
|
|
description:
|
|
- Where the Docker repository key is stored.
|
|
docker_apt_list_path:
|
|
type: path
|
|
default: /etc/apt/sources.list.d/docker.list
|
|
description:
|
|
- APT source file written for the Docker repository.
|
|
docker_gpg_url:
|
|
type: str
|
|
default: https://download.docker.com/linux/ubuntu/gpg
|
|
description:
|
|
- URL of the repository signing key.
|
|
docker_repo_base_url:
|
|
type: str
|
|
default: https://download.docker.com/linux/ubuntu
|
|
description:
|
|
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
|
|
docker_apt_arch:
|
|
type: str
|
|
default: ""
|
|
description:
|
|
- >-
|
|
Architecture written into the APT source. Empty (the default) derives it from the host: C(x86_64) gives C(amd64), C(aarch64)
|
|
gives C(arm64). Any other host architecture fails the play, so set this to the name Docker publishes for it. Lowercase letters
|
|
and digits only. A value set here is always used.
|
|
docker_start_missed:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Installs C(/usr/local/sbin/docker-start-missed) and the unit C(docker-start-missed.service). After each boot the unit starts the
|
|
containers that Docker left down: exited with code 255 during this boot, with restart policy C(unless-stopped) or C(always). A
|
|
container stopped on purpose stays stopped. Setting it back to false removes the unit and the script.
|
|
- >-
|
|
Meant for a host that runs Docker with C(live-restore), where dockerd's restore pass can skip a container after a reboot of the
|
|
whole host. The unit does nothing when C(/usr/bin/docker) does not exist.
|
|
docker_start_missed_settle_seconds:
|
|
type: int
|
|
default: 30
|
|
description:
|
|
- Seconds the unit waits after Docker answers, so dockerd's own restarts finish before it judges what is still down. At least 0.
|
|
docker_stop_at_shutdown:
|
|
type: bool
|
|
default: false
|
|
description:
|
|
- >-
|
|
Installs C(/usr/local/sbin/docker-stop-at-shutdown) and the unit C(docker-stop-at-shutdown.service), started by the role, whose stop
|
|
action runs at host shutdown after Docker has stopped and before the network and remote file systems. It sends SIGTERM to every
|
|
container process, waits up to C(docker_stop_at_shutdown_timeout) seconds, then SIGKILL. It never uses C(docker stop) or
|
|
C(docker kill), which would set the manually-stopped marker. Setting it back to false removes the unit and the script. The role
|
|
never stops the running unit, because stopping it runs its stop action and ends every container.
|
|
- >-
|
|
The unit is ordered before C(docker.service) and after C(network-online.target) and C(remote-fs.target), and that ordering
|
|
also applies at boot: Docker then starts only after the network and the remote file systems are up. The script reads the
|
|
layout of the systemd cgroup driver on cgroup v2 (C(/sys/fs/cgroup/system.slice/docker-<id>.scope)); on a host that lays
|
|
containers out differently it finds nothing, says so in the journal and changes nothing.
|
|
- >-
|
|
Meant for a host that runs Docker with C(live-restore) and whose containers mount NFS shares: without it a container holding
|
|
a mount blocks the shutdown in the kernel's final unmount once the network is gone. The unit does nothing when
|
|
C(/usr/bin/docker) does not exist.
|
|
docker_stop_at_shutdown_timeout:
|
|
type: int
|
|
default: 30
|
|
description:
|
|
- Seconds the unit waits for container processes to end after SIGTERM before it sends SIGKILL. At least 1.
|
|
docker_service:
|
|
type: str
|
|
default: docker
|
|
description:
|
|
- Name of the systemd unit that is enabled, started, restarted and stopped.
|
|
docker_group:
|
|
type: str
|
|
default: docker
|
|
description:
|
|
- Group that C(docker_users) are added to.
|
|
docker_users:
|
|
type: list
|
|
elements: str
|
|
default: []
|
|
description:
|
|
- >-
|
|
Existing users added to C(docker_group) with append. Empty by default, because a role that installs after docker creates its
|
|
run-as user too late and must join the group itself.
|