2017-02-24 05:08:18 +01:00
|
|
|
---
|
2017-05-10 04:36:53 +02:00
|
|
|
- name: Ensure old versions of Docker are not installed.
|
|
|
|
package:
|
2018-10-23 06:32:38 +02:00
|
|
|
name:
|
|
|
|
- docker
|
2023-11-10 16:20:54 +01:00
|
|
|
- docker.io
|
2018-10-23 06:32:38 +02:00
|
|
|
- docker-engine
|
2017-05-10 04:36:53 +02:00
|
|
|
state: absent
|
|
|
|
|
2017-09-19 10:19:58 +02:00
|
|
|
- name: Ensure dependencies are installed.
|
2017-02-24 05:08:18 +01:00
|
|
|
apt:
|
2018-07-22 23:02:44 +02:00
|
|
|
name:
|
|
|
|
- apt-transport-https
|
|
|
|
- ca-certificates
|
2017-02-24 05:08:18 +01:00
|
|
|
state: present
|
2022-12-14 18:25:29 +01:00
|
|
|
when: docker_add_repo | bool
|
2017-02-24 05:08:18 +01:00
|
|
|
|
2021-03-26 10:19:45 +01:00
|
|
|
- name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems).
|
2021-03-23 07:53:43 +01:00
|
|
|
apt:
|
|
|
|
name: gnupg2
|
|
|
|
state: present
|
|
|
|
when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<')
|
|
|
|
|
2021-03-26 10:19:45 +01:00
|
|
|
- name: Ensure additional dependencies are installed (on Ubuntu >= 20.04).
|
2021-03-24 03:26:04 +01:00
|
|
|
apt:
|
|
|
|
name: gnupg
|
|
|
|
state: present
|
2022-06-17 14:08:44 +02:00
|
|
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=')
|
2021-03-24 03:26:04 +01:00
|
|
|
|
2023-11-17 03:59:51 +01:00
|
|
|
- name: Ensure directory exists for /etc/apt/keyrings
|
|
|
|
file:
|
|
|
|
path: /etc/apt/keyrings
|
|
|
|
state: directory
|
|
|
|
mode: '0755'
|
2017-05-24 01:05:34 +02:00
|
|
|
|
2023-12-18 20:06:21 +01:00
|
|
|
- name: Add Docker apt key.
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ docker_apt_gpg_key }}"
|
|
|
|
dest: /etc/apt/keyrings/docker.asc
|
|
|
|
mode: '0644'
|
|
|
|
force: false
|
|
|
|
checksum: "{{ docker_apt_gpg_key_checksum | default(omit) }}"
|
|
|
|
register: add_repository_key
|
|
|
|
ignore_errors: "{{ docker_apt_ignore_key_error }}"
|
|
|
|
when: docker_add_repo | bool
|
2023-11-17 03:59:51 +01:00
|
|
|
|
2023-11-17 06:20:56 +01:00
|
|
|
- name: Change permissions for /etc/apt/keyrings/docker.gpg
|
2023-11-17 03:59:51 +01:00
|
|
|
file:
|
|
|
|
path: /etc/apt/keyrings/docker.gpg
|
|
|
|
mode: 'a+r'
|
2017-02-24 05:08:18 +01:00
|
|
|
|
|
|
|
- name: Add Docker repository.
|
|
|
|
apt_repository:
|
|
|
|
repo: "{{ docker_apt_repository }}"
|
|
|
|
state: present
|
2022-08-09 02:11:52 +02:00
|
|
|
filename: "{{ docker_apt_filename }}"
|
2018-09-27 05:13:32 +02:00
|
|
|
update_cache: true
|
2022-12-14 16:31:46 +01:00
|
|
|
when: docker_add_repo | bool
|