Files
Kamino/roles/docker/tasks/unit_absent.yml
T
Dragonish 567e9cca7c
Build / build (pull_request) Successful in 27s
Lint / lint (pull_request) Successful in 2m15s
Molecule / molecule (pull_request) Successful in 4m17s
feat(docker): add opt-in boot and shutdown units for hosts that run Docker with live-restore
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
2026-11-25 17:31:37 +00:00

36 lines
1.3 KiB
YAML

---
# Takes one of the role's units out: disable it, delete its files, tell systemd. A running unit is not stopped, because stopping
# docker-stop-at-shutdown runs its stop action and ends every container. Needs __docker_unit_name and __docker_unit_script.
- name: Disable {{ __docker_unit_name }}
become: true
ansible.builtin.systemd:
name: "{{ __docker_unit_name }}.service"
enabled: false
register: __docker_unit_disabled
# The unit may not exist (systemd: "Could not find the requested service"): there is nothing to disable.
failed_when:
- __docker_unit_disabled.failed | default(false)
- "'Could not find the requested service' not in (__docker_unit_disabled.msg | default(''))"
when: not ansible_check_mode
tags: [docker, configure, remove]
- name: Remove the files of {{ __docker_unit_name }}
become: true
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "/etc/systemd/system/{{ __docker_unit_name }}.service"
- "{{ __docker_unit_script }}"
register: __docker_unit_removed
tags: [docker, configure, remove]
- name: Reload systemd after removing {{ __docker_unit_name }}
become: true
ansible.builtin.systemd:
daemon_reload: true
when:
- __docker_unit_removed is changed
- not ansible_check_mode
tags: [docker, configure, remove]