From f1644ed138cb7a98193e4813aca5ff1a90a7c7cd Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 18 Mar 2023 19:52:55 +0100 Subject: [PATCH] docker: source list for Debian 12 --- docker-host/tasks/main.yml | 24 ++++++++++++++++-------- docker-host/templates/docker.sources.j2 | 8 ++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 docker-host/templates/docker.sources.j2 diff --git a/docker-host/tasks/main.yml b/docker-host/tasks/main.yml index b73fde0b..163ec76c 100644 --- a/docker-host/tasks/main.yml +++ b/docker-host/tasks/main.yml @@ -11,11 +11,17 @@ - name: Install source requirements apt: name: - - apt-transport-https - ca-certificates - gnupg2 state: present +- name: Install apt-transport-https (Debian <10) + apt: + name: + - apt-transport-https + state: present + when: ansible_distribution_major_version is version('10', '<') + - name: Add Docker's official GPG key copy: src: docker-debian.asc @@ -25,17 +31,19 @@ owner: root group: root -- name: Add Docker repository +- name: Add Docker repository (Debian <12) apt_repository: repo: 'deb [signed-by={{ apt_keyring_dir }}/docker-debian.asc] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable' + filename: docker.list state: present - filename: docker.list + when: ansible_distribution_major_version is version('12', '<') -- name: Drop unsigned Docker repository - apt_repository: - repo: 'deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable' - state: absent - filename: docker.list +- name: Add Docker repository (Debian >=12) + ansible.builtin.template: + src: docker.sources.j2 + dest: /etc/apt/sources.list.d/docker.sources + state: present + when: ansible_distribution_major_version is version('12', '>=') - name: Install Docker apt: diff --git a/docker-host/templates/docker.sources.j2 b/docker-host/templates/docker.sources.j2 new file mode 100644 index 00000000..5e349774 --- /dev/null +++ b/docker-host/templates/docker.sources.j2 @@ -0,0 +1,8 @@ +# {{ ansible_managed }} + +Types: deb +URIs: https://download.docker.com/linux/debian +Suites: {{ ansible_distribution_release }} +Components: stable +Signed-by: {{ apt_keyring_dir }}/docker-debian.asc +Enabled: yes \ No newline at end of file