Explorar o código

fix(ansible): replace deprecated apt_key with deb822_repository in docker-install-ubuntu

- Remove deprecated ansible.builtin.apt_key usage
- Replace apt_key + apt_repository with modern deb822_repository
- Add package cleanup for conflicting Docker packages
- Include missing docker-ce-cli and containerd.io components
- Update dependencies according to the current official Docker Documentation

_(NB: None of the code in this commit is AI-generated. AI has only been used to review the code and enhance the commit message.)_
Fabrizio hai 1 mes
pai
achega
5b01152178
Modificáronse 1 ficheiros con 25 adicións e 15 borrados
  1. 25 15
      library/ansible/docker-install-ubuntu/main.yml.j2

+ 25 - 15
library/ansible/docker-install-ubuntu/main.yml.j2

@@ -5,32 +5,42 @@
   gather_facts: true
 
   tasks:
-    - name: Install docker dependencies
+    - name: Remove conflicting packages
+      ansible.builtin.apt:
+        name:
+          - docker.io
+          - docker-compose
+          - docker-compose-v2
+          - docker-doc
+          - podman-docker
+          - containerd
+          - runc
+        state: absent
+
+    - name: Install docker/ansible dependencies
       ansible.builtin.apt:
         name:
-          - apt-transport-https
           - ca-certificates
           - curl
-          - gnupg-agent
-          - software-properties-common
+          - python3-debian
         update_cache: true
 
-    - name: Add docker gpg key
-      ansible.builtin.apt_key:
-        url: https://download.docker.com/linux/ubuntu/gpg
-        state: present
-        keyring: /etc/apt/keyrings/docker.gpg
-
-    - name: Add docker repository
-      ansible.builtin.apt_repository:
-        filename: docker
-        repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {% verbatim %}{{ ansible_lsb.codename | lower }}{% endverbatim %} stable
-        state: present
+    - name: Add docker repository with docker key from URL
+      ansible.builtin.deb822_repository:
+        name: docker
+        types: deb
+        uris: https://download.docker.com/linux/ubuntu
+        suites: '{{ ansible_distribution_release }}'
+        components: stable
+        architectures: amd64
+        signed_by: https://download.docker.com/linux/ubuntu/gpg 
 
     - name: Install docker engine
       ansible.builtin.apt:
         name:
           - docker-ce
+          - docker-ce-cli
+          - containerd.io
           - docker-buildx-plugin
           - docker-compose-plugin
         update_cache: true