Files
ansible-edge/roles/setup/tasks/docker.yml
2025-01-22 00:06:35 +01:00

48 lines
1.2 KiB
YAML

---
- name: Install prerequisites for Docker
ansible.builtin.apt:
name:
- ca-certificates
- curl
state: present
update_cache: true
become: true
- name: Create /etc/apt/keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
- name: Download Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.asc
mode: "0644"
- name: Add Docker repository
ansible.builtin.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
ansible.builtin.apt:
update_cache: true
- name: Install Docker packages
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
- name: Add current user to docker group
ansible.builtin.user:
name: "{{ ansible_user_id }}"
groups: docker
append: true