57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
---
|
|||
|
|
- name: Assert supported operating system
|
||
|
|
ansible.builtin.assert:
|
||
|
|
that:
|
||
|
|
- ansible_facts.os_family == 'Debian'
|
||
|
|
- ansible_facts.distribution in ['Ubuntu', 'Debian']
|
||
|
|
fail_msg: This role supports Ubuntu and Debian hosts.
|
||
|
|
|
||
|
|
- name: Install Docker repository prerequisites
|
||
|
|
ansible.builtin.apt:
|
||
|
|
name:
|
||
|
|
- ca-certificates
|
||
|
|
- curl
|
||
|
|
- gnupg
|
||
|
|
state: present
|
||
|
|
update_cache: true
|
||
|
|
|
||
|
|
- name: Create APT keyrings directory
|
||
|
|
ansible.builtin.file:
|
||
|
|
path: /etc/apt/keyrings
|
||
|
|
state: directory
|
||
|
|
mode: "0755"
|
||
|
|
|
||
|
|
- name: Download Docker signing key
|
||
|
|
ansible.builtin.get_url:
|
||
|
|
url: "https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}/gpg"
|
||
|
|
dest: /etc/apt/keyrings/docker.asc
|
||
|
|
mode: "0644"
|
||
|
|
|
||
|
|
- name: Configure Docker APT repository
|
||
|
|
ansible.builtin.apt_repository:
|
||
|
|
repo: >-
|
||
|
|
deb [arch={{ {'x86_64':'amd64','aarch64':'arm64'}.get(ansible_facts.architecture, ansible_facts.architecture) }}
|
||
|
|
signed-by=/etc/apt/keyrings/docker.asc]
|
||
|
|
https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}
|
||
|
|
{{ ansible_facts.distribution_release }} stable
|
||
|
|
filename: docker
|
||
|
|
state: present
|
||
|
|
|
||
|
|
- name: Install Docker Engine and Compose plugin
|
||
|
|
ansible.builtin.apt:
|
||
|
|
name:
|
||
|
|
- docker-ce
|
||
|
|
- docker-ce-cli
|
||
|
|
- containerd.io
|
||
|
|
- docker-buildx-plugin
|
||
|
|
- docker-compose-plugin
|
||
|
|
state: present
|
||
|
|
update_cache: true
|
||
|
|
|
||
|
|
- name: Enable and start Docker
|
||
|
|
ansible.builtin.systemd_service:
|
||
|
|
name: docker
|
||
|
|
state: started
|
||
|
|
enabled: true
|
||
|
|
|