Files
Kamino/roles/traefik/tasks/binary/download.yml
Defame1297 ab0ce421cc
Build / build (pull_request) Canceled after 0s
Lint / lint (pull_request) Canceled after 0s
Molecule / molecule (pull_request) Canceled after 0s
feat(traefik): add traefik_release_url for a release mirror
The archive and checksums URLs were hardcoded to the GitHub releases.
traefik_release_url (default: the GitHub release directory of
traefik_version, as before) lets a host download from a mirror.

The Molecule scenario uses it: verify's update path now downloads
stand-in releases that prepare.yml builds under /opt/molecule-download
(a stub binary answering `version`, its archive and a sha256sum
checksums file), so it no longer fetches two more real releases per
host. The converge still downloads the real release from GitHub, which
keeps the default URL proven. traefik_verify_other_version moves to the
scenario's group vars so prepare and verify share it. The update path
leaves the stub installed, which the README and verify now state.

Verify replaces the fixed 15 s pause with a poll (30 x 2 s) for an
"Unable to obtain ACME certificate" log line stamped at or after the
running process's ExecMainStartTimestamp, so a line left by the
process converge restarted does not count. It fails closed on a
missing start time, a missing line or an unparseable stamp. It then
asserts NRestarts
is 0, since Restart=always would hide a crash.

Assisted-by: Claude Code:claude-opus-5-5
2026-11-27 15:36:34 +00:00

70 lines
2.9 KiB
YAML

---
# The one download of the Traefik release, shared by install.yml (extracts straight into the
# live binary's directory, since nothing runs yet) and update.yml (extracts into a staging
# directory next to it, before the service is stopped). Only the traefik binary is extracted:
# the archive also holds CHANGELOG.md and LICENSE.md, which do not belong in a bin directory.
# Input: traefik_download_dir, the directory the binary is extracted into.
# Tagged install and update: an include does not pass its tags on to the tasks it includes,
# so under --tags update a task tagged install only would be skipped.
- name: Download, verify and extract the Traefik binary
block:
# force: an archive left in /tmp by an earlier run (an interrupted run, or another tool)
# would otherwise be kept and then fail the checksum check.
- name: Download Traefik archive
ansible.builtin.get_url:
url: "{{ traefik_release_url }}/{{ traefik_archive_name }}"
dest: "{{ traefik_local_archive }}"
mode: "0644"
force: true
tags: [traefik, install, binary, update]
- name: Download Traefik checksums
ansible.builtin.get_url:
url: "{{ traefik_release_url }}/traefik_{{ traefik_version }}_checksums.txt"
dest: /tmp/traefik_checksums.txt
mode: "0644"
force: true
tags: [traefik, install, binary, update]
- name: Compute SHA256 of Traefik archive
ansible.builtin.command: sha256sum {{ traefik_local_archive }}
# The archive is not downloaded under --check, so there is nothing to hash, verify or unpack.
when: not ansible_check_mode
register: traefik_sha256
changed_when: false
failed_when: traefik_sha256.stdout is not match("^[a-f0-9]{64} ")
tags: [traefik, install, binary, update]
- name: Verify Traefik checksum against official list
ansible.builtin.shell: |
grep -F "{{ traefik_sha256.stdout.split()[0] }} {{ traefik_archive_name }}" /tmp/traefik_checksums.txt
when: not ansible_check_mode
register: traefik_checksum_verify
changed_when: false
failed_when: traefik_checksum_verify.rc != 0
tags: [traefik, install, binary, update]
- name: Extract the Traefik binary
become: true
ansible.builtin.unarchive:
src: "{{ traefik_local_archive }}"
dest: "{{ traefik_download_dir }}"
remote_src: true
include: [traefik]
owner: root
group: root
mode: "0755"
when: not ansible_check_mode
tags: [traefik, install, binary, update]
always:
- name: Remove the downloaded Traefik archive and checksums
ansible.builtin.file:
path: "{{ traefik_download_file }}"
state: absent
loop:
- "{{ traefik_local_archive }}"
- /tmp/traefik_checksums.txt
loop_control:
loop_var: traefik_download_file
tags: [traefik, install, binary, update]