Files
ansible-edge/roles/setup/tasks/docker.yml
Tuan-Dat Tran 40a7e1dab7 initial commit
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2025-01-21 23:13:01 +01:00

47 lines
1.0 KiB
YAML

---
- name: Install prerequisites for Docker
apt:
name:
- ca-certificates
- curl
state: present
update_cache: yes
- name: Create /etc/apt/keyrings directory
file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
- name: Download Docker GPG key
get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.asc
mode: "0644"
- name: Add Docker repository
apt_repository:
repo: "deb [arch={{ ansible_architecture }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
filename: docker
state: present
- name: Update apt cache after adding Docker repo
apt:
update_cache: yes
- name: Install Docker packages
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
- name: Add current user to docker group
user:
name: "{{ ansible_user_id }}"
groups: docker
append: yes