ansible-role-docker/tasks/main.yml
2025-01-10 19:41:39 +02:00

55 lines
1.2 KiB
YAML

---
- name: Install dependencies.
ansible.builtin.apt:
name:
- ca-certificates
- curl
state: present
- name: Create apt keys installation directory.
ansible.builtin.file:
path: "/etc/apt/keyrings"
state: directory
mode: "0755"
- name: Add docker apt key.
ansible.builtin.get_url:
url: "https://download.docker.com/linux/ubuntu/gpg"
dest: "/etc/apt/keyrings/docker.asc"
mode: "0444"
- name: Add docker apt repository.
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu noble stable"
filename: docker
state: present
update_cache: true
- name: Install docker apt packages.
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
- name: Start and enable docker service.
ansible.builtin.service:
name: docker
state: started
enabled: true
- name: Install service parameters file.
ansible.builtin.template:
src: docker.j2
dest: "/etc/default/docker"
owner: root
group: root
mode: "0644"
notify:
- Restart docker service