From af6092576ce7f35f443799fd6e2993c2eb20ad46 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 16 Jul 2022 16:54:51 +0200 Subject: [PATCH 1/2] Add a template for the docker apt list This template is necessary because the apt_repository role cannot determine if an entry should be replaced. --- roles/docker_setup/templates/docker.list.j2 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 roles/docker_setup/templates/docker.list.j2 diff --git a/roles/docker_setup/templates/docker.list.j2 b/roles/docker_setup/templates/docker.list.j2 new file mode 100644 index 0000000..7795847 --- /dev/null +++ b/roles/docker_setup/templates/docker.list.j2 @@ -0,0 +1,2 @@ +deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable + From b75205f96c91474c01f3767dce529c133595c373 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 16 Jul 2022 16:39:28 +0200 Subject: [PATCH 2/2] Use template to replace Docker apt list entry --- roles/docker_setup/tasks/main.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/docker_setup/tasks/main.yml b/roles/docker_setup/tasks/main.yml index 2d3a475..43c8614 100644 --- a/roles/docker_setup/tasks/main.yml +++ b/roles/docker_setup/tasks/main.yml @@ -29,11 +29,15 @@ state: present - name: add Docker's APT repository - apt_repository: - repo: deb https://download.docker.com/linux/debian buster stable - state: present + ansible.builtin.template: + src: templates/docker.list.j2 + dest: /etc/apt/sources.list.d/docker.list + register: apt_repo + +- name: Update package cache + ansible.builtin.apt: update_cache: true - filename: "docker" + when: apt_repo.changed - name: install Docker package: