Files
docker/docker.yaml
2023-11-24 15:10:24 +02:00

54 lines
1.5 KiB
YAML

- name: Set Docker repo architecture
ansible.builtin.set_fact:
docker_arch: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'ansible_architecture' }}"
- name: Install prerequisites for Docker repository
ansible.builtin.apt:
name:
- ca-certificates
- curl
- gnupg2
- lsb-release
state: latest
- name: Add Docker's APT key
ansible.builtin.apt_key:
#url: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg"
# ^ ex: Ubuntu -> ubuntu
url: "https://download.docker.com/linux/ubuntu/gpg"
state: present
ignore_errors: yes
- name: Add Docker's APT repo
ansible.builtin.apt_repository:
# repo: "deb [arch={{ docker_arch }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
repo: "deb [arch={{ docker_arch }}] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
ignore_errors: yes
- name: Install docker and dependencies
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
- name: Start and enable Docker daemon
become: yes
ansible.builtin.service:
name: docker
state: started
enabled: yes
- name: Start and enable Containerd daemon
become: yes
ansible.builtin.service:
name: containerd
state: started
enabled: yes