Files
Kamino/roles/docker/tasks/update.yml
T
Defame1297andClaude Sonnet 5.5 aad59fc339
Build / build (pull_request) Failing after 22s
Lint / lint (pull_request) Successful in 15s
Molecule / molecule (pull_request) Successful in 2m18s
feat(docker): add the docker role (#522)
Extracted from the environment repository, wave 1. Scrubbed of private
references: namespace mortis, no repository paths or issue numbers in
comments and docs, the removed docker_ufw_rules guard dropped, the molecule
scenario uses the FQCN and no provisioner environment overrides.
ansible-lint mocks the role's FQCN because CI checks the Collection out
outside an ansible_collections path.

Verified: the commit hooks. Not verified: the molecule scenario (CI only).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-08 18:59:26 +00:00

62 lines
2.2 KiB
YAML

---
# Run with docker_update=true (tag: update).
- name: Refresh APT cache before checking for Docker updates
become: true
ansible.builtin.apt:
update_cache: true
tags: [docker, update]
- name: Determine latest available candidate version for each Docker package
ansible.builtin.command: "apt-cache policy {{ item }}"
register: docker_apt_policy
changed_when: false
# Read-only, so it also runs in the --check preview. Skipped there, there is no stdout to read the
# candidate from.
check_mode: false
loop: "{{ docker_packages }}"
loop_control:
label: "{{ item }}"
tags: [docker, update]
- name: Extract candidate version for each Docker package
ansible.builtin.set_fact:
docker_candidates: >-
{{ docker_candidates | default({}) | combine({item.item:
item.stdout | regex_search('Candidate:\s+(\S+)', '\1')
| default([''], true) | first}) }}
loop: "{{ docker_apt_policy.results }}"
loop_control:
label: "{{ item.item }}"
tags: [docker, update]
- name: Fail if any Docker package has no installable candidate
ansible.builtin.fail:
msg: >-
No installable candidate version found for Docker package '{{ item.key }}'
(apt-cache policy reported candidate '{{ item.value }}'). Check that the
Docker APT repo is reachable and the package name in docker_packages is
correct.
loop: "{{ docker_candidates | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: not item.value or item.value == '(none)'
tags: [docker, update]
# Pinned to each package's resolved candidate version (never state=latest)
# so this task stays idempotent and passes ansible-lint's package-latest rule.
- name: Build pinned package=version list from candidates
ansible.builtin.set_fact:
docker_pinned_packages: "{{ docker_pinned_packages | default([]) + [item.key ~ '=' ~ item.value] }}"
loop: "{{ docker_candidates | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags: [docker, update]
- name: Update Docker Engine packages to latest candidate versions
become: true
ansible.builtin.apt:
name: "{{ docker_pinned_packages }}"
state: present
notify: Restart docker
tags: [docker, update]