Skip to content

Commit

Permalink
docker: use recursive cleanup from python and mainline for apt reposi…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
saltydk committed Jul 2, 2024
1 parent 2ce7f6a commit 02d6510
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
4 changes: 0 additions & 4 deletions roles/docker/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ docker_apt_key_url: https://download.docker.com/linux/ubuntu/gpg

docker_apt_repo_version: stable

docker_apt_repo_url_old: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_repo_version }}" # noqa line-length

docker_apt_repo_url_old2: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_repo_version }}" # noqa line-length

docker_apt_repo_url: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_repo_version }}" # noqa line-length

docker_apt_repo_filename: docker
Expand Down
33 changes: 23 additions & 10 deletions roles/docker/tasks/subtasks/binary/binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
# GNU General Public License v3.0 #
#########################################################################
---
- name: Binary | Identify apt source files
ansible.builtin.find:
paths: /etc/apt/sources.list.d/
recurse: no
register: apt_source_files

- name: Binary | Check if file contains 'download.docker.com'
ansible.builtin.slurp:
path: "{{ item.path }}"
register: file_contents
loop: "{{ apt_source_files.files }}"

- name: Binary | Remove apt source files containing 'download.docker.com'
ansible.builtin.file:
path: "{{ item.item.path }}"
state: absent
loop: "{{ file_contents.results }}"
when: "'download.docker.com' in item.content | b64decode"

- name: Binary | Update APT package index
ansible.builtin.apt:
update_cache: yes

- name: Binary | Add official gpg signing key to trusted.gpg.d
ansible.builtin.get_url:
url: "{{ docker_apt_key_url }}"
Expand All @@ -17,16 +40,6 @@
delay: 10
until: result is succeeded

- name: Binary | Remove old official repository entries
ansible.builtin.apt_repository:
repo: "{{ item }}"
filename: "{{ docker_apt_repo_filename }}"
update_cache: true
state: absent
loop:
- "{{ docker_apt_repo_url_old }}"
- "{{ docker_apt_repo_url_old2 }}"

- name: Binary | Add official repository
ansible.builtin.apt_repository:
repo: "{{ docker_apt_repo_url }}"
Expand Down

0 comments on commit 02d6510

Please sign in to comment.