Files
semaphore/playbooks/install-standard-docker.yml

54 lines
1.4 KiB
YAML

---
- name: Install Docker using official Docker documentation steps
hosts: docker
become: true
vars:
docker_keyring_path: /etc/apt/keyrings/docker.asc
docker_repo_list_path: /etc/apt/sources.list.d/docker.list
tasks:
- name: Ensure required packages are installed
apt:
name:
- ca-certificates
- curl
state: present
update_cache: yes
- name: Ensure keyring directory exists
file:
path: /etc/apt/keyrings
state: directory
mode: "0755"
- name: Download Docker's official GPG key
get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: "{{ docker_keyring_path }}"
mode: "0644"
register: docker_key_download
- name: Add Docker repository to Apt sources
copy:
dest: "{{ docker_repo_list_path }}"
content: |
deb [arch={{ ansible_architecture }} signed-by={{ docker_keyring_path }}] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable
notify: Update apt cache
- name: Install Docker packages
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
update_cache: no # already handled by handler
handlers:
- name: Update apt cache
apt:
update_cache: yes