Newer
Older
---
- name: Add GPG key for Docker repository (Ubuntu).
apt_key:
state: present
id: "{{ docker_gpg_key['Ubuntu']['id'] }}"
url: "{{ docker_gpg_key['Ubuntu']['url'] }}"
when: ansible_distribution == "Ubuntu"
- name: Add Docker repository (Ubuntu).
apt_repository:
repo: deb {{ docker_repo_url['Ubuntu'] }} {{ ansible_lsb.codename }} stable
when: ansible_distribution == "Ubuntu"
- name: Add Docker repository (CentOS).
yum_repository:
name: docker-ce
description: Docker CE
state: present
baseurl: "{{ docker_repo_url['CentOS'] }}"
gpgkey: "{{ docker_gpg_key['CentOS']['url'] }}"
gpgcheck: true
when: ansible_distribution == "CentOS"
- name: Install Docker (Ubuntu).
package:
name:
- docker-ce=5:19.03.*
- docker-ce-cli=5:19.03.*
- containerd.io=1.3.*
- python3-docker # Needed for Ansible's Docker modules.
state: present
when: ansible_distribution == "Ubuntu"
- name: Install Docker (CentOS).
package:
name:
- docker-ce-19.03.*
- docker-ce-cli-19.03.*
- containerd.io-1.3.*
- python-docker-py # Needed for Ansible's Docker modules.
state: present
when: ansible_distribution == "CentOS"
- name: Install python3-docker (CentOS).
vars:
ansible_python_interpreter: python3
pip:
name:
- docker>=2.1.0,<3.0
state: present
when: ansible_distribution == "CentOS"
- name: Enable and start Docker service.
service:
name: docker
enabled: true
state: started