ansible/roles/docker/tasks/install.yml

68 lines
1.2 KiB
YAML

---
- name: Uninstall old versions
apt:
name: "{{ item }}"
state: absent
purge: true
loop:
- docker
- docker-engine
- docker.io
- containerd
- runc
become: true
- name: Update cache
apt:
update_cache: true
become: true
- name: Install dependencies for apt to use repositories over HTTPS
apt:
name: "{{ item }}"
state: present
loop:
- ca-certificates
- curl
- gnupg
- lsb-release
become: true
- name: Create keyrings direcoty
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
become: true
- name: Add Docker apt key.
ansible.builtin.get_url:
url: "{{ docker_apt_gpg_key }}"
dest: /etc/apt/trusted.gpg.d/docker.asc
mode: '0664'
force: true
become: true
- name: Add Docker repository.
apt_repository:
repo: "{{ docker_apt_repository }}"
state: present
become: true
- name: Update cache
apt:
update_cache: true
become: true
- name: Install Docker Engine, containerd, and Docker Compose.
apt:
name: "{{ item }}"
state: present
loop:
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- containerd.io
become: true