--- # 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: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/{{ 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: "https://github.com/traefik/traefik/releases/download/{{ traefik_version }}/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]