From b1e3faf0da612d52ee0feb6860a9219c102b64d0 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 10 Aug 2025 18:30:28 +0200 Subject: [PATCH] Debian: adjust way GPG signature is installed for Docker's software repo. --- .../targets/setup_docker/tasks/Debian.yml | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/integration/targets/setup_docker/tasks/Debian.yml b/tests/integration/targets/setup_docker/tasks/Debian.yml index d1953d18..30f71375 100644 --- a/tests/integration/targets/setup_docker/tasks/Debian.yml +++ b/tests/integration/targets/setup_docker/tasks/Debian.yml @@ -14,13 +14,33 @@ update_cache: true notify: cleanup docker -- name: Add gpg key - shell: curl -fsSL https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg >key && apt-key add key +- when: + - (ansible_facts.distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int) >= 22) or + (ansible_facts.distribution == "Debian" and (ansible_facts.distribution_major_version | int) >= 12) + name: Add Docker repo on Ubuntu 22+ or Debian 12+ + block: + - name: Add gpg key + get_url: + url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg" + dest: /etc/apt/keyrings/docker.asc -- name: Add Docker repo - apt_repository: - repo: deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable - state: present + - name: Add Docker repo + apt_repository: + repo: deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable + state: present + +- when: + - (ansible_facts.distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int) < 22) or + (ansible_facts.distribution == "Debian" and (ansible_facts.distribution_major_version | int) < 12) + name: Add Docker repo on Ubuntu 20 or before, or Debian 11 or before + block: + - name: Add gpg key + shell: curl -fsSL https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg >key && apt-key add key + + - name: Add Docker repo + apt_repository: + repo: deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable + state: present - block: - name: Prevent service restart