From 8d958fd3942c243f2c5360436e8dd121a2e33b1a Mon Sep 17 00:00:00 2001 From: modem7 Date: Fri, 15 Apr 2022 23:58:22 +0100 Subject: [PATCH] Update setup-Debian.yml Update to remove apt_key. This module is deprecated, and this is the Debian guideline workaround until https://github.com/ansible/ansible/pull/77340 is released. Further info: https://www.reddit.com/r/ansible/comments/u2vy26/comment/i4pbgj9/ --- tasks/setup-Debian.yml | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index cc444ca..b10e93f 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -25,27 +25,31 @@ state: present when: ansible_distribution == 'Ubuntu' or ansible_distribution_version is version('20.04', '>=') -- name: Add Docker apt key. - apt_key: - url: "{{ docker_apt_gpg_key }}" - id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 - state: present - register: add_repository_key - ignore_errors: "{{ docker_apt_ignore_key_error }}" - - name: Ensure curl is present (on older systems without SNI). package: name=curl state=present when: add_repository_key is failed -- name: Add Docker apt key (alternative for older systems without SNI). - shell: > - curl -sSL {{ docker_apt_gpg_key }} | apt-key add - - args: - warn: false - when: add_repository_key is failed +- name: Remove gpg keys if they exist #otherwise GPG doesn't run if file already exists + file: + path: "{{ item }}" + state: absent + with_items: + - /usr/share/keyrings/docker-archive-keyring.gpg + - /usr/share/keyrings/docker-archive-keyring.gpg_armored -- name: Add Docker repository. - apt_repository: - repo: "{{ docker_apt_repository }}" - state: present - update_cache: true +- name: Download Docker gpg key + get_url: + url: https://download.docker.com/linux/ubuntu/gpg + dest: /usr/share/keyrings/docker-archive-keyring.gpg_armored + checksum: sha256:1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570 # curl -sL https://download.docker.com/linux/ubuntu/gpg|sha256sum + +- name: De-Armor Docker GPG key + shell: gpg --dearmor < /usr/share/keyrings/docker-archive-keyring.gpg_armored > /usr/share/keyrings/docker-archive-keyring.gpg + args: + creates: /usr/share/keyrings/docker-archive-keyring.gpg + +- name: "Add Docker's repository to APT sources list" + apt_repository: + repo: "deb [arch={{ docker_apt_arch }}] signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] {{ docker_repo_url }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" + state: present + update_cache: true \ No newline at end of file