Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@
- software-properties-common
- unzip

- name: Create /etc/apt/keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'

- name: Add Docker GPG apt key
ansible.builtin.apt_key:
ansible.builtin.get_url:
url: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
state: present
dest: /etc/apt/keyrings/docker.asc
mode: '0644'

- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
repo: deb [arch={{ ansible_architecture | replace('x86_64', 'amd64') | replace('aarch64', 'arm64') }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
state: present
Comment on lines 30 to 33
Copy link
Copy Markdown

@ThoSap ThoSap Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a filename so this custom apt repository lands in the subfolder sources.list.d
https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/apt_repository_module.html
You may have to cleanup the old sources list file (manually or with Ansible once).

I suggest docker-ce(.list) (CE stands for Community Edition), same as Docker uses it for other OS:
Image

With this, we have a predictable repo source list name, otherwise it is dependent on the URL.

Suggested change
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
repo: deb [arch={{ ansible_architecture | replace('x86_64', 'amd64') | replace('aarch64', 'arm64') }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
state: present
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb [arch={{ ansible_architecture | replace('x86_64', 'amd64') | replace('aarch64', 'arm64') }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
filename: docker-ce
state: present


- name: Update apt and install docker-ce
Expand Down